Hi.
PHP's mail() function often doesn't work very well. One of the main
problems is that mail typically has an envelope sender of the username
of your account on your web server. This can be bad for many reasons,
one of which being that there may be no MX records for that particular
host, but there are plenty of other potential problems caused by this.
The From: address that you specify in PHP's mail() is the from address
that appears in the mail's headers, but it's not the only from address
in an email message. The other one is the envelope sender address
specified within the SMTP communication itself which can be
different. And with php mail() will almost certainly be different.
If you're on a Windows server, then one solution is to simply to add
something like:
ini_set('sendmail_from', '[email protected]');
before the call to mail() or to otherwise configure php.ini with the
same. This sets the envelope sender.
On some linux/*ix servers you can simply add an additional argument to
PHP mail() to specify options to sendmail to set the envelope sender,
for example:
mail($to, $subject, $message, $headers, "-f [email protected]");
however, overriding the envelope sender in this way requires
permission that won't necessarily have.
The most generic option (and therefore recommended way) is to use
something like Zend_Mail and use SMTP transport. There are many PHP
SMTP mail options out there, find one that best suits your
environment. Most of them will make it much easier to send attachments
too. You generally don't have to worry about the envelope sender at
all when using these packages.
If you're stuck, i have a php mail() replacement around that uses SMTP
and works exactly like PHP mail().
-Craig
On 19/05/2009, at 5:54 PM, henson wrote:
> I'm having this problem with sending HTML mail to my yahoo.com email.
--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---