Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not authenticate - with Office365 #1257

Closed
LingaTigeen opened this issue Nov 28, 2017 · 7 comments
Closed

Could not authenticate - with Office365 #1257

LingaTigeen opened this issue Nov 28, 2017 · 7 comments

Comments

@LingaTigeen
Copy link

Hi,
I'm using the latest version of PHPMailer for office365. The connection isn't succeeded with tls. I'm getting erros like authentication failed, but I verified the email and password and it is correct. I tried connecting with thunderbird for double checking the smtp, it works well. I don't understand why it is showing logs like authentication failed.

Here is my log.

2017-11-28 19:03:37 Connection: opening to smtp.office365.com:587, timeout=300, options=array()
2017-11-28 19:03:37 Connection: opened
2017-11-28 19:03:37 SERVER -> CLIENT: 220 BM1PR01CA0104.outlook.office365.com Microsoft ESMTP MAIL Service ready at Tue, 28 Nov 2017 19:03:38 +0000
2017-11-28 19:03:37 CLIENT -> SERVER: EHLO localhost
2017-11-28 19:03:37 SERVER -> CLIENT: 250-BM1PR01CA0104.outlook.office365.com Hello [124.123.71.13]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-STARTTLS250-8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8
2017-11-28 19:03:37 CLIENT -> SERVER: STARTTLS
2017-11-28 19:03:37 SERVER -> CLIENT: 220 2.0.0 SMTP server ready
2017-11-28 19:03:37 CLIENT -> SERVER: EHLO localhost
2017-11-28 19:03:37 SERVER -> CLIENT: 250-BM1PR01CA0104.outlook.office365.com Hello [124.123.71.13]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-AUTH LOGIN XOAUTH2250-8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8
2017-11-28 19:03:37 CLIENT -> SERVER: AUTH LOGIN
2017-11-28 19:03:37 SERVER -> CLIENT: 334 VXNlcm5hbWU6
2017-11-28 19:03:37 CLIENT -> SERVER: <credentials hidden>
2017-11-28 19:03:37 SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2017-11-28 19:03:37 CLIENT -> SERVER: <credentials hidden>
2017-11-28 19:03:46 SERVER -> CLIENT: 535 5.7.3 Authentication unsuccessful [BM1PR01CA0104.INDPRD01.PROD.OUTLOOK.COM]
2017-11-28 19:03:46 SMTP ERROR: Password command failed: 535 5.7.3 Authentication unsuccessful [BM1PR01CA0104.INDPRD01.PROD.OUTLOOK.COM]
SMTP Error: Could not authenticate.
2017-11-28 19:03:46 CLIENT -> SERVER: QUIT
2017-11-28 19:03:46 SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel
2017-11-28 19:03:46 Connection: closed
SMTP Error: Could not authenticate.
Message could not be sent.Mailer Error: SMTP Error: Could not authenticate.

This is the part of my code :

$mail->SMTPDebug = 3;                                 // Enable verbose debug output
$mail->isSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp.office365.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = '******';                 // SMTP username
$mail->Password = '******';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587;

Can you please help me identify and fix the issue?

@Synchro
Copy link
Member

Synchro commented Nov 28, 2017

Your code all looks correct. If you set SMTPDebug = 4 it will include your encoded ID and password (for you to verify - don't post it here). If you're sure it's correct, I can only suggest you talk to Office365 support.

@Synchro Synchro closed this as completed Dec 11, 2017
@valentinoPereira
Copy link

need a solution for this problem.. Im stuck on this too

@LingaTigeen
Copy link
Author

It is with the office365 mail. Check on the admin side whether the user has the rights to access with the email clients. Try to connect with email clients like Thunderbird first and if it doesn't work, it should be a problem with the email configuration. Contact the email administrator to provide all the options.

@ubarbaxor
Copy link

ubarbaxor commented Sep 19, 2019

I've been having a similar issue - posting here as it's the third result when googling "could not authenticate outlook phpmailer tls".
It seems $mail->SMTPAuth" can't be set to true with $mail->SMTPSecure = 'SSL'.
For some reason, after removing SMTPAuth it works with Outlook.

@Synchro
Copy link
Member

Synchro commented Sep 19, 2019

It's nothing to do with auth. $mail->SMTPSecure = 'SSL' is not a valid setting; It should be $mail->SMTPSecure = 'ssl'.

@zabi-hac
Copy link

zabi-hac commented Sep 6, 2021

https://www.youtube.com/watch?v=Ydalru8_TmY&ab_channel=TeeVee

try this in your office365 account and wait for a while

search it in settings of outlook 'smtp'
tls
587

try staty safe from malappuram kerala india

@zabi-hac
Copy link

zabi-hac commented Sep 6, 2021

use the outlook mail id at setfrom too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants