[BlueOnyx:07850] Re: php mail function issue
Michael Stauber
mstauber at blueonyx.it
Mon Jul 25 17:33:34 -05 2011
Hi Chris,
> While I understand why the "wrong" solution here is wrong, it would also
> be "wrong" to try to force / educate every site owner on the box to use
> WordPress in a way that is different from the vast majority of the
> world's installations. So how can I make it "right?"
I've just seen your offlist email and already replied to that. Here is my
answer that I emailed you offlist, just for the list archives:
By default the PHP mail() function doesn't really let you set a sender. Which
is just a major "Doh!"
After all, any MTA expects a working sender address as the origin of your
message, right? And you certainly would like that the recipient of the message
can reply back to you, too.
So PHP and ultimately Apache will just assume some defaults for you, which
often do not work. After all, why should they? Especially if you have a dozen
sites on the server, then there certainly is no default sender address that
works for all of them, right?
You can get around this by two ways:
In /etc/php.ini (for Solarspeed PHP that's /home/solarspeed/php/etc/php.ini)
you find this line:
sendmail_path = /usr/sbin/sendmail -t -i
... and change it to this:
sendmail_path = /usr/sbin/sendmail -t -i -f working at email.address
... where "working at email.address" is a working and valid email address that is
used as new default sender for all emails sent with the mail() function.
However, with that you are back at "square one": All scripts that use the
mail() function will use this sender address. Which may not really be what
you're looking for.
Another way is to put this into your PHP script, somewhere above the code
where you use the mail() function:
ini_set("SMTP","smtp.example.com" );
ini_set('sendmail_from', 'user at example.com');
That then overrides (or sets) the settings in php.ini to the ones you've
specified in the script.
Of course you'd replace "smtp.example.com" and 'user at example.com' with stuff
that works for you.
--
With best regards
Michael Stauber
More information about the Blueonyx
mailing list