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

220 Like 24 Dislike
Previous php-forum Next php-forum
Other php-forum

undefined offset help
Hi All,

I kept getting undefined offset PHP notice for a simple for loop. For eg
$va = arr

Display the user's weight lost in the past week
Hello everyone,

I am working on a weight loss app for my site, and I want to display the user

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
what is wrong with this

Code: [Select]<?php
if ($_SERVER['HTTP_REFERER'])
{

How a counter of users ? such as ---> (231 Viewing)
I want to count how many users are actually viewing the page, How is that possible?
Thank you guy

Need help: how to catch acess of undefined class properties
Hello. I am learning OO with PHP and have hit a problem.
Some code runs as perfectly valid code,

Multiple Pages
Hi. Im very new to php. I'm trying to create a basic login/registration page.

So I have a bas

Need help with an email blocker for a guessbook
I am new with php and here is a simple guessbook page but I am being hit with spam from a group of t

upload photo limits
ive got a upload photo script and im just trying to make more secure currently it limits size and as

Adding meta tags under Zend FW
Hello there, recently has come to my hands the FTP of a website which is running under Zend, I would

Just wondering what you think about my site
I am new to phpfreaks i just seen this form and thought it would be cool to see what other thought a

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