如何使用带有localhost SMTP的PHPMailer将邮件发送到gmail?

时间:2014-05-18 13:08:28

标签: php email phpmailer

我尝试使用PHPMailer发送电子邮件,这里是我的代码:

require '/PHPMailer-master/PHPMailerAutoload.php';
$mailltoadm = new PHPMailer;
$mailltoadm->isSMTP();     
$mailltoadm->Host = 'localhost';  
$mailltoadm->SMTPAuth = true;     
$mailltoadm->Username = 'admin@queenshifa.com';  
$mailltoadm->Password = 'mypasswordhere';  
$mailltoadm->SMTPSecure = 'tls'; 
$mailltoadm->From = $emaillogin; 
$mailltoadm->FromName = $userloginname; 
$mailltoadm->addAddress($mastermaill, $name_store);
$mailltoadm->addAddress($mastermaill);  
$mailltoadm->addReplyTo($emaillogin, $userloginname);
$mailltoadm->WordWrap = 50;
$mailltoadm->isHTML(true);  
$mailltoadm->Subject = 'New Order '. $name_store;
$mailltoadm->Body    = $finishorder; 
$mailltoadm->AltBody = convert_html_to_text($finishorder);
if(!$mailltoadm->send()) 
{
   echo 'Mailer to admin Error: ' . $mailltoadm->ErrorInfo;
} 
else 
{
   echo 'Message to admin has been sent';
}

为什么电子邮件发送到@ yahoo.com成功,但不发送到@ gmail.com?
任何人都可以帮助我。

1 个答案:

答案 0 :(得分:0)

如果您真的可以在@yahoo上收到电子邮件而且没有@gmail,那么简单就意味着Google阻止了您的电子邮件。您一定要检查Gmail上的垃圾邮件文件夹,因为您的电子邮件可能就在那里。