我面临一个奇怪的问题,在我的PHP脚本。我做了一个函数发送电子邮件,并在我的PHP页面调用函数。功能工作正常,当我发送邮件到雅虎或任何其他域名,但失败,当谈到将邮件发送到Gmail的account.below是我的代码PHP邮件功能不发送电子邮件到Gmail帐户
function send_mail($p_to , $p_sub, $p_body)
{
$from = '[email protected]';
$to = $p_to;
$email_subject = $p_sub;
$email_body = $p_body;
$xheaders = "";
$xheaders .= "From: <$from>\n";
$xheaders .= "X-Sender: <$from>\n";
$xheaders .= "X-Mailer: PHP\n"; // mailer
$xheaders .= "X-Priority: 1\n"; //1 Urgent Message, 3 Normal
$xheaders .= "Content-Type:text/html; charset=\"iso-8859-1\"\n";
mail($to,$email_subject,$email_body,$xheaders);
}
// 当我直接将邮件发送到Gmail帐户例如,如果通过为所有字段($ p_to,$ p_subject,$ p_body)提供硬编码值并使用上述代码创建新页面并发送邮件,那么它就可以工作。
它工作得很好,并发送邮件到gmail帐户,但不知何故停止工作的gmail.i检查垃圾桶也没有发现。 任何想法frnds?
这可能是[灰名单(http://support.google.com/mail/answer/180063?hl=en)。对于未经验证的网域,Gmail有时会拒绝传入的电子邮件,以查看域名是否会尝试重新发送。 – George 2013-04-22 17:52:54
但我能够使用硬编码值发送邮件。我如何检查看到它的灰色列出或不? – user2015610 2013-04-22 17:56:39
看来你的变量的实际值有问题吗? ($ p_to,$ p_sub和$ p_body)? – bestprogrammerintheworld 2013-04-22 17:59:29