1

I'm at a complete loss right now.

I did plenty of research regarding this issue. Some background: I'm sending a HTML email through PHP using PHPMailer. The problem is, it always ends up in the junk folder.

$message = "<html><u>Hello there</u></html>";
date_default_timezone_set('Etc/UTC');
$mail = new PHPMailer();

 //even tried setting up SMTP server 
$mail->IsSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = "myGmailEmail@gmail.com";
$mail->Password = "my gmail password";
$mail->SMTPDebug = 2;
$mail->Port = 587;
$mail->SMTPSecure = 'tls';

$mail->setFrom('noreply@promisingwebsite.com', 'No-reply');
$mail->addReplyTo('noreply@promisingwebsite.com', 'No-reply');
$mail->AddAddress($to);
$mail->IsHTML(true);  
$mail->Subject  =  $subject;
$mail->MsgHTML($message);
if($mail->send()) resp(true,$code);
else resp(false,"error (".$mail->ErrorInfo.")");

When I do not use SMTP, it sends the email which ends up in junk folder. When I DO use it, I cannot authenticate:

    2016-11-26 12:44:16 CLIENT -> SERVER: EHLO 185.80.130.141
2016-11-26 12:44:16 CLIENT -> SERVER: STARTTLS
2016-11-26 12:44:16 CLIENT -> SERVER: EHLO 185.80.130.141
2016-11-26 12:44:16 CLIENT -> SERVER: AUTH LOGIN
2016-11-26 12:44:16 CLIENT -> SERVER: bmVkdWthczE3QGdtYWlsLmNvbQ==
2016-11-26 12:44:17 CLIENT -> SERVER: bmVkdWxpdWthczEyMw==
2016-11-26 12:44:17 SMTP ERROR: Password command failed: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbtT
                                      534-5.7.14 KhjtVSQhqL8MciQEtofR0fc36pPSF1zUxFnNZCay9DTcpxzjY0-elaKn8oWgt_-7bXpCSU
                                      534-5.7.14 L0sarBbOFwjA4l3lN_VmEDi1Pej1C4gHpfDiFnpC87Md82FK_qZe2B6J1olxCWnmQUQlWE
                                      534-5.7.14 eIwqtsXjE3xia_Y-lJnGZu7uQeQ7L_4QYj452Xxllf6GjA9Pz-cJsanxzXl7NTqRKEhcGM
                                      534-5.7.14 hTxqiKtVHXjFtkWZ_fGs5O960iNwk> Please log in via your web browser and
                                      534-5.7.14 then try again.
                                      534-5.7.14  Learn more at
                                      534 5.7.14  https://support.google.com/mail/answer/78754 e102sm10342631lfi.25 - gsmtp
2016-11-26 12:44:17 SMTP Error: Could not authenticate.
2016-11-26 12:44:17 CLIENT -> SERVER: QUIT
2016-11-26 12:44:17 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

I have no idea what to do. I ran spamcheck tests but they return somewhat a negative result (email is not classified as spam). Thanks for your help.

Ned
  • 361
  • 3
  • 16
  • maybe because your from email is not a gmail ? – Buddhi741 Nov 26 '16 at 13:23
  • i use my own mail server with a letsencript certificate made life easier for me – Buddhi741 Nov 26 '16 at 13:24
  • Did you try adding a plain text version of the email? See this question: http://stackoverflow.com/questions/22507176/send-html-and-plain-text-email-simultaneously-with-php-mailer – Schwesi Nov 26 '16 at 13:44

1 Answers1

0

The reason is because you are trying to send an email through Google's SMTP servers but setting the reply to and from email address as something different then the gmail account that it is coming from. Spam filters hate it when things don't match up.

If you changed the reply to and from email address to myGmailEmail@gmail.com I'd beat that it won't be marked as spam.

If your host is providing email for your domain then the best beat is to use that SMTP server and not Google's.

Winter Faulk
  • 413
  • 4
  • 9