Jump to content

Setting/Modify Headers using mail() function


gatoruss

Recommended Posts

I have a question about setting email headers when using mail() in a php script.

 

When I send an email from an email account set up domain (using, for example, xxx@MyDomain.net) and then view the header in the email that was received by the recipient account, the "Received:" header reads, in part, as follows:

 

Received: from localhost ([xxx.x.x.x] helo=www.MyDomain.net)

by servername.host.com with esmtpa (Exim 4.69)

(envelope-from <xxx@MyDomain.net>)

id xxxxx-xxxxxxx-xx

 

However, when I send an email using a script that I am working on that uses the mail() function, I set the "From:" and "Return-path" to an email address I have for my domain (YYY@MyDomain.net). When I look at the header in the email that was received by the recipient account, the "Received:" header has my CPanel user name in it - and that kind of makes me nervous (as my host preaches not to disclose that to anyone).  In particular, here is what the "Received:" header looks like:

 

Received: from cPanelUserName by servername.host.com with local (Exim 4.69)

(envelope-from YYY@MyDomain.net)

id xxxxx-xxxxxxx-xx; Sat, 21 Nov 2009 21:36:09 -0500

 

Here is the code snippet I am using to send email and set headers:

 

//Some additional email headers

$add_headers = 'From: YYY@MyDomain.net' . "\r\n". "Return-path: YYY@MyDomain.net" . "\r\n";

mail('XXX@MyDomain.net', $subject , $message , $add_headers, "-f YYY@MyDomain.net");

 

I have tried to modify the "Received:" header by adding some text to the header via the mail() function (for example, "Received:  SOME TEST]"), but it doesn't change the "Received:" header.

 

Please note, I don't want to make the header fraudulent, but I would prefer not to disclose my cPanel username.  I would just like the "Received:" header to resemble the first one quoted above.

 

I have checked with my host's help desk, they suggested it was not a server issue, but a scripting issue. They suggested I try their scripting forum for assistance.  I posted there, but no one there has shed any light on this yet.  So, I thought that I would try here.

 

I tried researching this on the Internet, and thus far I have not found any info on how to successfully modify "Received:" header with mail().  Info I have come across seems to suggest that this is a server issue and not something that can be changed via a script (at least via a script using mail()).  If that is the case, I am thinking I should stop looking for a solution using mail(), and take a different approach.

 

Any suggestions?

 

Thanks

 

Russ

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.