3 Replies - 1205 Views - Last Post: 07 December 2015 - 11:14 AM Rate Topic: -----

#1 DocNet   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 11-October 12

Phpmailer gmail SMTP authentication error?

Posted 04 December 2015 - 11:11 AM

Something i definetly made wrong, so i want to know where is problem because i get authentication error.

  • I already have few gmail accounts,
  • i create new one for my website,
  • i added new email in "Account and import" to my old gmail account.
  • i copy my new email username and password to phpmailer code


include_once('phpmailer/class.phpmailer.php');
include_once('phpmailer/class.smtp.php');
//6nb5Drv;
function sendmail(){
$mail = new PHPMailer();  

$mail->IsSMTP();                                      // set mailer to use SMTP
$mail->SMTPAuth = true;     // turn on SMTP authentication
$mail->SMTPSecure = "tls";
$mail->Host = "smtp.gmail.com";  // specify main and backup server
$mail->Port = 587; // Set the SMTP port i tried and 457
$mail->Username = '[email protected]';                // SMTP username
$mail->Password = 'newmailpass';                  // SMTP password

$mail->SMTPDebug  = 1;                     // enables SMTP debug information (for testing)
                                           // 1 = errors and messages
                                           // 2 = messages only

$mail->From = '[email protected]';
$mail->FromName = 'From';
$mail->AddAddress('[email protected]', 'To');  // Add a recipient

$mail->IsHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <strong>in bold!</strong>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->Send()) {
   echo 'Message could not be sent.';
   echo 'Mailer Error: ' . $mail->ErrorInfo;
   exit;
}

echo 'Message has been sent';
}
sendmail();


but i get authentication error. What is wrong? Probably something with credentials, how to create gmail smtp?

Debug report:

Quote

2015-12-04 17:56:15 CLIENT -> SERVER: EHLO www.site.co 2015-12-04 17:56:15 CLIENT -> SERVER: STARTTLS 2015-12-04 17:56:15 CLIENT -> SERVER: EHLO www.site.co 2015-12-04 17:56:15 CLIENT -> SERVER: AUTH LOGIN 2015-12-04 17:56:15 CLIENT -> SERVER: UHJlZGljdG9sb2d5 2015-12-04 17:56:15 CLIENT -> SERVER: U2dHZlB0VHZUbTZ1SW9ZMi1qTlNCQQ== 2015-12-04 17:56:17 SMTP ERROR: Password command failed: 435 4.7.8 Error: authentication failed: UGFzc3dvcmQ6 2015-12-04 17:56:17 SMTP Error: Could not authenticate. 2015-12-04 17:56:17 CLIENT -> SERVER: QUIT 2015-12-04 17:56:17 SMTP connect() failed. https://github.com/P...Troubleshooting Message could not be sent.Mailer Error: SMTP connect() failed. https://github.com/P...Troubleshooting


If you have some easier free SMTP, please paste link here.
2 days i am trying to send stupid mail from cloudways server,
they don't support classic mail(), they have addon for mailgun, mandrill,stmpauth, but am i stupid or what each time i fail.
For mandrill i get message sent, but when i check inbox there was not mail.
Than i check mandrill log and i see that i need to verify on cloudways that domain i created, but on cloudways there is no option to check mail.

I need radical solution now, thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: Phpmailer gmail SMTP authentication error?

#2 andrewsw   User is offline

  • Entwickler
  • member icon

Reputation: 6604
  • View blog
  • Posts: 26,911
  • Joined: 12-December 12

Re: Phpmailer gmail SMTP authentication error?

Posted 04 December 2015 - 11:13 AM

I would try setting SMTPDebug to 2 or 3 to get more info.

It does say "Password command failed" so double-check the username/password combination.
Was This Post Helpful? 0
  • +
  • -

#3 DocNet   User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 118
  • Joined: 11-October 12

Re: Phpmailer gmail SMTP authentication error?

Posted 04 December 2015 - 11:28 AM

View Postandrewsw, on 04 December 2015 - 11:13 AM, said:

I would try setting SMTPDebug to 2 or 3 to get more info.

It does say "Password command failed" so double-check the username/password combination.

Username and password are correct, i think that problem is how i created gmail smtp.

Let say that this is mail what i already had:

[email protected]

and i created new mail:

[email protected]

so i add [email protected] to [email protected] (i googled that this is way how to create gmail smtp) //this part is suspected
and now i use
[email protected]
newmailpass
in phpmailer.
Was This Post Helpful? 0
  • +
  • -

#4 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2105
  • View blog
  • Posts: 6,443
  • Joined: 15-January 14

Re: Phpmailer gmail SMTP authentication error?

Posted 07 December 2015 - 11:14 AM

If you base64-decode those values in the error, the value for "authentication failed" is just "Password: ". It sounds like a blank or incorrect password.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1