Php Mail Problem
I have a problem with one of the websites i'm administrating. All emails sent from the website have this email address at the top: php5.2.4.winX@glodns.ne开发者_StackOverflow中文版t How can i get rid of it.
The answers already given about an additional from:
header may not work at all if the sendmail application on your server is not propertly configured.
From the website php.net (http://php.net/manual/en/function.mail.php#72715):
To change the envelope "from" address on unix, you specify an "-r" option to your sendmail binary. You can do this globally in php.ini by adding the "-r" option to the "sendmail_path" command line. You can also do it programmatically from within PHP by passing "-r address@domain.com" as the "additional_parameters" argument to the mail() function (the 5th argument). If you specify an address both places, the sendmail binary will be called with two "-r" options, which may have undefined behavior depending on your sendmail implementation. With the Postfix MTA, later "-r" options silently override earlier options, making it possible to set a global default and still get sensible behavior when you try to override it locally.
On Windows, the the situation is a lot simpler. The envelope "from" address there is just the value of "sendmail_from" in the php.ini file. You can override it locally with ini_set().
see http://www.php.net/manual/en/function.mail.php
This function you can pass additional headers. What you need to do is add an additional header as follows:
"From: <youremail@example.com>"
OR:
set a default in your php.ini:
sendmail_from = me@myserver.com
The mail()
function accepts a $additionl_headers
parameter, use it to pass the 'From: '
header:
mail($to, $subject, $message, "From: webmaster@example.com");
You need to set the from address - You just need a "From: you@example.com" in the mail()
function's headers argument.
精彩评论