I've configured several headers in the mail()
function, sender name and other fields appear as set. But, in the gmail m开发者_开发技巧ailed-by
field, I see the hostname of my server, even though I've set the Mailed-By header to be different... Is there a way to change this, or am I specifying the wrong header to effect the change?
Current Headers:
From: no-reply@example.com Mailed-By: Example.com X-Mailer: Example/1.0
If you post the headers you are sending it will be easier to diagnose the issue. But the header should be "X-Mailer" to set the application mailed-by field, as far as I know. If that does not work, post your current headers and we can help you further / better.
EDIT:
Doing some further research, it seems the 5th parameter with the "-f" flag would be the way to do it:
mail($to, $message, $body, $headers, '-fnoreply@yourmailer.com');
Is a possibility. That is generally an email address, so you would have to see what values it accepts etc. I found this information from the Joyent Discussion Board.
But reading that it may not be what you want.
-fname Sets the name of the
from'' person (i.e., the sender of the mail). -f can only be used by
trusted'' users (normally root, daemon, and network) or if the person you are trying to become is the same as the person you are.
From the sendmail Man page. I will see if I cannot strum anything else up.
It sounds like that mailed-by header was added by your mail transfer agent, or gmail, after it left PHP. Sounds like it may be a security measure so abuse reports can be tracked down.
I don't know if this has been solved as it's old but I had the same issue on a contact page from my website. We wanted club members to be able to use a form to contact the officers. But I wanted it to look like it came from the e-mail address the user entered so the officer could respond directly. I found this code and modified it for my site.
$headers = "From: <$email> \n";
$headers .= "X-Sender: <$from>\n";
$headers .= "X-Mailer: PHP\n";
$email is the address the user entered. I can't say I understand it all but it solved my issue.
You Cannot Set the Mailed-by option of your own. you have to publish your spf record and should have DKIM signature for this. For extra Information click on this link.
https://support.google.com/mail/answer/180707?hl=en
精彩评论