View Full Version : mail() header from: Always Changed to Server's Address

07-16-2008, 04:07 PM

I have a simple mail function like this:

$headers = 'From: '.$myName.' <'.$myMail.'>'."\r\n".
'Reply-To: '.$myMail."\r\n".
'Return-Path: '.$myMail."\r\n".
'X-Mailer: PHP/'.phpversion();
mail($sendTo, $subject, $message, $headers);
The problem is, when the email arrived at one's inbox... the "From: "
header is always changed to <user>@ns123.hostname.com.

That was when I used my host's email accounts or of my other hosts.
But when I put some free addresses from services like GMail/Yahoo,
it went through without hassle (name and address remains unchanged).

Anybody can tell me what actually is going on, and maybe
the proper setup for the hosting's email accounts, so this
can just work properly?

Thank you in advance,


07-17-2008, 11:48 AM
Your PHP code has no errors. This problem may caused by your mail server configuration (postfix, sendmail, mdaemon or exchange...). If you are server administrator, look for "ns123.hostname.com". You will get mail configuration file to edit. Otherwise, contact your server administrator.

07-18-2008, 12:24 PM
First, thanks for the reply.
But I'm afraid that isn't the case, because if it IS... then when I put
Yahoo/GMail address as the FROM: header, it would also be altered, right?

Well, it's not. If I put something like username@gmail.com, the FROM:
header would successfully be sent, nothing altered.