PHPMailer sending e-mails with the warning: This message may not have been sent by: foo@gmail.com Learn more Report phishing

混江龙づ霸主 提交于 2019-12-01 00:59:44

问题


I am using PHPMailer to send automated e-mails from my website and while testing, I noticed that all e-mails sent by php mailer are generating the following warning on the recipients end:

This message may not have been sent by: foo@gmail.com Learn more Report phishing

I was wondering if there is a way to avoid this?

PHP Mailer code:

//mail functions
require("mailer/class.phpmailer.php");
require("mailer/class.smtp.php");
require("mailer/class.pop3.php");

$mail = new PHPMailer();
$mail->IsSMTP();  
$mail->Host = "relay-hosting.secureserver.net";
$mail->Port = 25;  
$mail->IsHTML(true);
$mail->Username = "foo@gmail.com";  // SMTP username
$mail->Password = "pass"; // SMTP password

$mail->From = "foo@gmail.com";
$mail->FromName = "FOO";
$mail->AddAddress("fOO@gmail.com", "WIDB");
$mail->AddReplyTo("foo@gmail.com");
//$mail->AddAddress("foo@gmail.com");                  // name is optional

$mail->WordWrap = 50;                                 // set word wrap to 50 characters
//$mail->AddAttachment("/var/tmp/file.tar.gz");         // add attachments
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");    // optional name
$mail->IsHTML(true);                                  // set email format to HTML

$mail->Subject = 'Foo - Transaction Receipt';
$mail->Body    = $message;
$mail->AltBody = "nothing";

//send mail
$mail->Send();

I am using GMail and I have SMTP enabled...


回答1:


You can either set up google apps for your site and get a Username@yourwebsite.com gmail account (more info here it's free), or You will need to set up an e-mail address on your current server that is Username@yourwebsite.com and use that as the $mail->from address.

Your E-Mail recipients are receiving the message because you are telling google to send an e-mail from your server, and then you are telling them that the mail is coming from gmail, which it isn't, it's coming from your personal server. Since the from address and your server address don't match, they flag it as spam. This is googles way of preventing spam, to them it would be the same if you put $mail->from(YOURMOM@LOL.com). The e-mail would still send, but your domain name does not match the @ address.




回答2:


Apart from following the above guidelines, here something I noticed that might help someone.

When I sent an email with body "Please check the attached work order" and a pdf attachment, gmail showed it with a spam warning(inside inbox)

When I sent an email with body "Your work order has been attached" and the same pdf attachment, gmail didn't show any warning.

I'm using java api for sending emails



来源:https://stackoverflow.com/questions/11726820/phpmailer-sending-e-mails-with-the-warning-this-message-may-not-have-been-sent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!