Reputation: 1787
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: [email protected] How can i get rid of it.
Upvotes: 0
Views: 395
Reputation: 5597
You need to set the from address - You just need a "From: [email protected]" in the mail()
function's headers argument.
Upvotes: 0
Reputation: 918
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 [email protected]" 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().
Upvotes: 3
Reputation: 554
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: <[email protected]>"
OR:
set a default in your php.ini:
sendmail_from = [email protected]
Upvotes: 2
Reputation: 13003
The mail()
function accepts a $additionl_headers
parameter, use it to pass the 'From: '
header:
mail($to, $subject, $message, "From: [email protected]");
Upvotes: 1