Phpmailer: Sending via Office365 SMTP failed. Password command failed

Created on 24 Jan 2018  路  6Comments  路  Source: PHPMailer/PHPMailer

Hi, I'm trying to set up a PHP-Script which is working with PHP-Mailer to send Mails from an internal server to our customer.

require_once('/scripts/PHPMailer-master/PHPMailerAutoload.php');    
$mail = new PHPMailer();   
$mail->CharSet = 'UTF-8';   
$mail->isSMTP();   
$mail->SMTPDebug = 2;   
$mail->Host = "smtp.office365.com";   
$mail->Port = 587;   
$mail->SMTPSecure = 'tls';   
$mail->SMTPAuth = true;   
$mail->Username = [email protected];   
$mail->Password = "password"; 

I already set up a connector on the Office 365 Exchange.
The extension=php_openssl.dll in php.ini is set up as well.
Credentials were checked multiple times and if I enter a wrong Password there is the same error message. I hope someone knows a possible solution for this Problem.

2018-01-24 07:08:16 SERVER -> CLIENT: 220 VI1PR08CA0095.outlook.office365.com Microsoft ESMTP MAIL Service ready at Wed, 24 Jan 2018 07:08:16 +0000 
2018-01-24 07:08:16 CLIENT -> SERVER: EHLO input 
2018-01-24 07:08:16 SERVER -> CLIENT: 250-VI1PR08CA0095.outlook.office365.com Hello [62.2.201.50] 250-SIZE 157286400 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-STARTTLS 250-8BITMIME 250-BINARYMIME 250-CHUNKING 250 SMTPUTF8 
2018-01-24 07:08:16 CLIENT -> SERVER: STARTTLS 
2018-01-24 07:08:16 SERVER -> CLIENT: 220 2.0.0 SMTP server ready 
2018-01-24 07:08:16 CLIENT -> SERVER: EHLO input 
2018-01-24 07:08:16 SERVER -> CLIENT: 250-VI1PR08CA0095.outlook.office365.com Hello [62.2.201.50] 250-SIZE 157286400 250-PIPELINING 250-DSN 250-ENHANCEDSTATUSCODES 250-AUTH LOGIN XOAUTH2 250-8BITMIME 250-BINARYMIME 250-CHUNKING 250 SMTPUTF8 
2018-01-24 07:08:16 CLIENT -> SERVER: AUTH LOGIN 
2018-01-24 07:08:16 SERVER -> CLIENT: 334 VXNlcm5hbWU6 
2018-01-24 07:08:16 CLIENT -> SERVER: xxx= 
2018-01-24 07:08:16 SERVER -> CLIENT: 334 UGFzc3dvcmQ6 
2018-01-24 07:08:16 CLIENT -> SERVER: xxx= 
2018-01-24 07:08:22 SERVER -> CLIENT: 535 5.7.3 Authentication unsuccessful [VI1PR08CA0095.eurprd08.prod.outlook.com] 
2018-01-24 07:08:22 SMTP ERROR: Password command failed: 535 5.7.3 Authentication unsuccessful [VI1PR08CA0095.eurprd08.prod.outlook.com] 
2018-01-24 07:08:22 SMTP Error: Could not authenticate. 
2018-01-24 07:08:22 CLIENT -> SERVER: QUIT 
2018-01-24 07:08:22 SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel 
2018-01-24 07:08:22 SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting

Thank you.

Most helpful comment

We just had this problem (535 5.7.3 Authentication unsuccessful) on our hosted exchange.. Enabling GSSAPI on the Exchange server fixed it. :)

All 6 comments

We've seen this before in #189, where it turned out to be inconsistent behaviour from Office365 - the same code and credentials worked at one point, not at another. I've seen mention elsewhere of needing to create app-specific passwords in office365. You could also try XOAUTH2 authentication, though it's more complex to set up.

I can also tell you're using an old version of PHPMailer - please upgrade.

$mail->Username = [email protected];
Your mail adress is a string, so use " or ';
example : $mail->Username = '[email protected]';

We just had this problem (535 5.7.3 Authentication unsuccessful) on our hosted exchange.. Enabling GSSAPI on the Exchange server fixed it. :)

Pls can someone chat me up private...i need to be having serious issue in getting php mailer...Can someone please help me with this, and i compensate for this...please... i need a good mailer php, that i can be sending mails to my clients...Please

@bibz0r @edenpark59 Pls kindly be of help.... Admin, is it wrong to drop my icq or email here ..

@billjave Download the latest version, or ideally install it into your app using composer (as the readme says), write code to use it based on the examples and documentation, if you have trouble, read more docs, read questions on Stack Overflow, and if you still have trouble, ask specific questions and describe exactly what your problem is.

Don't demand private help for undefined problems by hijacking unrelated questions, hassling those that are also asking questions, it just annoys everyone. If you don't know how to write scripts, employ someone that does.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

aduh95 picture aduh95  路  4Comments

webmasterHPCR picture webmasterHPCR  路  3Comments

AndroidDesigner picture AndroidDesigner  路  4Comments

velocius picture velocius  路  4Comments

weirdeagle picture weirdeagle  路  3Comments