Setting/Modify Headers using mail() function


Posted on 16th Feb 2014 07:03 pm by admin

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:

QuoteReceived: 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:

QuoteReceived: 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:

Code: //Some additional email headers

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

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

No comments posted yet

Your Answer:

Login to answer
220 Like 24 Dislike
Previous forums Next forums
Other forums

Filling gaps in dates
So i'm doing a query for sales data and my return array looks like this

('date' => '20

modifying query string with no page refresh
Hi everybody,
I've tried to get info about my problem all over the internet but i didn't find out

Am I setting up my sites oldschool?
Ok,

When I create a site I open a basic template that I have created that consists of a css f

Is it a good practice to store user info. in sessions?
I am making a user class for my script which stores all the user information in sessions. It takes u

IF Statement & Two Tables With Different Echoes
I'm retrieving two tables in a single query using UNION ALL, like so:

Code: $query = "SE

$_FILES array
Ok,

I just started experimenting with PHP today. My goal right now is to have people be able

Change Sort Order to Display Newest File First
Hi Guys,

I have a page that sorts the contents (PDFs) of a directory and displays them on the

phpMailer not working ..........
HI,
I was playing with the phpMailer script and tried to send a smiple mail using their test scri

How to have a log of all the status a VIM document had been ?
Hi guys,

I’m using SAP Invoice Management plugin and the /OPT/VIM_ANALYTICS transa

Filtering for a phrase using pregmatch
Here is my code which looks for addresses which start with ' src=" '

Code: [Select]preg_

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash