From PHP.net mail function user's comments:
The most common problem people have with the mail() function is the failure to include an
additional header containing the from address in the call (along with the standard from
address). This commonly results in failed delivery due to spam filtering at the receiving end.
The solution: set your header-from address, or use this function:
<?
function MAIL_NVLP($fromname, $fromaddress, $toname, $toaddress, $subject, $message)
{
// Copyright ? 2005 ECRIA LLC, [url]http://www.ECRIA.com[/url]
// Please use or modify for any purpose but leave this notice unchanged.
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: \"".$fromname."\" <".$fromaddress.">\n";
return mail($toaddress, $subject, $message, $headers);
}
?>
and:
Sometimes using that headers:
$header = "Return-Path: [email]lostpass@website.net[/email]\n";
$header .= "X-Sender: [email]lostpass@website.net[/email]\n";
$header .= "From: This is my website <lostpass@website.net>\n";
$header .= "X-Mailer:PHP 5.1\n";
$header .= "MIME-Version: 1.0\n";
Gmail and Hotmail could consider it as "spam", so I just inserted before to send email:
ini_set(sendmail_from, "lostpass@mywebsite.net");
and ini_restore after it...