Cpanel API EmailTrack - Search: "from" vs "return-path"
In the API mentioned above (EmailTrack / Search function) I am unable to obtain the FROM: email address for a message included in the results if the FROM: email address was different than the RETURN-PATH email address in the originally sent message.
Example, my Perl script creates a mime message for sending an email from the server. In this case the $from email address is different than the $bounceto email address and they are placed in different header objects for the outgoing message:
$mime_msg = MIME::Lite->new(
From => $from,
Return-Path => $bounceto,
To => $to,
Bcc => $bcc,
Subject => $subject,
Type => "multipart/$multiparttype",
);
If the "from" address and "return-path" address are the same, there's no issue find a message in the search results using the "from" address. However, if the "return-path" address differs from the "from" address, only the "return-path" address seems to be returned in the API function call content.
The returned object distinguishes between the "recipient" and "deliveredto" fields on the TO: side, but I can't seem to find a distinction between the "from" email address and the "return-path" email addresses on the FROM: side. It seems that if they are different, the "email" field in the returned object record represents the "return-path" email address from the original message. When I dump the entire returned object record, I don't see the original "from" email address anywhere in that object.
Using this API function, is there some way to obtain the "from" email address from the original message when it differs from the "return-path" address?
Thanks!
-
Hey there! I did some testing on my end with this and I'm not finding a way to pull that data when the values differ. The best option in this situation would likely be a feature request to get that additional API functionality added to the product.
Would you like me to submit that request for you?
0 -
Thanks -- Yes, that would be great if you could submit that request on my behalf. Without it, the usefulness of the function is significantly diminished if the developer's goal is to search messages by the typical "from:" address.
As a matter of background, our website platform allows our customers to configure a distinct bounce/return-path address for all outgoing messages, as some want a specific administrator to deal with any bounces rather than the user who's email appears in the from: header, who typically wouldn't know how or have access to the parts of the system to correct the issue. While this is likely not the most typical use case, our "search email" app (our system's front-end that utilizes this API call) isn't particularly useful if they can't search by sender because it's always the same administrator's email address in the returned dataset.
Thanks again for the quick confirmation and follow-up.
0 -
You're very welcome! I've submitted that request and I'll bring it up during the next meeting, which is scheduled for Friday the 20th
I've made sure to link this thread to the request so I'll be sure to reply once I hear more.
0 -
Awesome -- thanks so much!
Is there a way for me to see the progress of the request, or are those requests only visible from your side?
0 -
Nope, no way for you to see those. BUT...I've linked this thread to the cases so if I hear updates on my end I'll be sure to post!
0 -
👍
0 -
Minor update - I talked with the features team and I'm reaching out to the email team directly to see if I can get some more information.
0 -
Thanks!
0 -
Vinnie Murdico - I'm working on this today and tomorrow and have a plan, but it'll likely be tomorrow before I have a full response to share with you. I'll update you as soon as I can!
0 -
Thanks -- That's great!
0 -
I did some testing on this and confirmed that Eximstats doesn't include the "From" or "Return-Path" header, which is why the search/API isn't able to retrieve that data. Here is a full list of what is available in the system:
cpapi2 --output=jsonpretty --user=cptesting EmailTrack search success=1 defer=0 | jq '.cpanelresult.data[] | select(.msgid | IN("1w3EgG-00000001V2E-28OZ","1w3EgH-00000001V2O-0r3d"))'
{
"actiontime": "2026-03-19 14:49:01",
"actionunixtime": 1773931741,
"deliveredto": "email1@cptesting.tld",
"deliverydomain": "cptesting.tld",
"deliveryuser": "cptesting",
"domain": "",
"email": "root@10-2-50-186.cprapid.com",
"host": "localhost",
"ip": "127.0.0.1",
"message": "Accepted",
"msgid": "1w3EgH-00000001V2O-0r3d",
"recipient": "email1@cptesting.tld",
"router": "virtual_user",
"sender": "root",
"senderauth": "localuser",
"senderhost": "localhost",
"senderip": "127.0.0.1",
"sendunixtime": 1773931741,
"size": 430,
"spamscore": "",
"transport": "dovecot_virtual_delivery",
"transport_is_remote": 0,
"type": "success",
"user": "root"
}I've created case CPANEL-52139 with our development team to see if they can get this added, but I'm not sure if they will change this since the older cpapi2 system is no longer in development. If anything there would likely be a new tool made under the uapi system that included this functionality.
I've linked this thread to the case so if I hear any updates on this I'll be sure to post!
0 -
Thanks! You mentioned that the returned object "doesn't include the "From" or "Return-Path" header", however, in my testing, it seems like the "email" field contains the "Return-Path" value. It's only the "From" header that can't be queried. In your tests, where did the "email" field value come from?
0 -
The "email" from my test was performed on the command line with this:
# echo -e "To: email1@cptesting.tld\nFrom: cptesting$(hostname)\Return-Path: cptesting$(hostname)\nSubject: SameFrom\n" | sendmail email1@cptesting.tld
so it makes sense that the "email" line said root@hostname in my case.
0 -
So, it does seem that the "email" field is at least valid coming back from the "Reply-To" header, correct? We're just missing "From"?
0 -
From my understanding those should match, yes. "From" seems to be the missing piece.
0 -
Got it -- thanks!
0
Please sign in to leave a comment.
Comments
16 comments