Page 1 of 1

microsoft 365 smtp wont authenticate but imap works

Posted: Mon Jul 08, 2024 3:26 am
by potato
Version of script: 3.4.5
Hosting company: ovh
What terms did you try when SEARCHING for a solution:
SMTP ERROR: Password command failed: 535 Incorrect authentication data

Write your message below:

I've followed this guide https://www.hesk.com/knowledgebase/?article=110

I am trying to setup OAuth for microsoft 365 and connecting fine over IMAP. When I set hesk to use SMTP server, and use the following I get an auth error:

SMTP Host: smtp.office365.com
SMTP Port: 587
Encryption: TLS
Do not validate server certificates: checked
Authentication method: OAuth
Username: my email

Code: Select all

2024-07-08 03:19:27	SERVER -> CLIENT: 220------.com ESMTP Exim 4.97.1 #2 Sun, 07 Jul 2024 22:19:27 -0500 
                   	                  220-We do not authorize the use of this system to transport unsolicited, 
                   	                  220 and/or bulk e-mail.
2024-07-08 03:19:27	CLIENT -> SERVER: EHLO --------.com
2024-07-08 03:19:27	SERVER -> CLIENT: ----------.com Hello -----vps.ovh.us [15.----]
                   	                  250-SIZE 52428800
                   	                  250-8BITMIME
                   	                  250-PIPELINING
                   	                  250-PIPECONNECT
                   	                  250-AUTH PLAIN LOGIN
                   	                  250-STARTTLS
                   	                  250 HELP
2024-07-08 03:19:27	CLIENT -> SERVER: STARTTLS
2024-07-08 03:19:27	SERVER -> CLIENT: 220 TLS go ahead
2024-07-08 03:19:27	CLIENT -> SERVER: EHLO -------.com
2024-07-08 03:19:27	SERVER -> CLIENT: -------.com Hello -----.vps.ovh.us [15.----]
                   	                  250-SIZE 52428800
                   	                  250-8BITMIME
                   	                  250-PIPELINING
                   	                  250-PIPECONNECT
                   	                  250-AUTH PLAIN LOGIN
                   	                  250 HELP
2024-07-08 03:19:27	CLIENT -> SERVER: AUTH LOGIN
2024-07-08 03:19:27	SERVER -> CLIENT: 334 VXNlcm5hbWU6
2024-07-08 03:19:27	CLIENT -> SERVER: [credentials hidden]
2024-07-08 03:19:27	SERVER -> CLIENT: 334 UGFzc3dvcmQ6
2024-07-08 03:19:27	CLIENT -> SERVER: [credentials hidden]
2024-07-08 03:19:29	SERVER -> CLIENT: 535 Incorrect authentication data
2024-07-08 03:19:29	SMTP ERROR: Password command failed: 535 Incorrect authentication data

Re: microsoft 365 smtp wont authenticate but imap works

Posted: Mon Jul 08, 2024 3:40 pm
by Klemen
Not sure what is wrong, but two things to try:

1. does the email account have SMTP/sending emails enabled?

2. does it work if you try connecting to SMTP using Basic authentication instead of OAuth?

Re: microsoft 365 smtp wont authenticate but imap works

Posted: Tue Jul 09, 2024 11:27 pm
by potato
The mailbox im trying to use for OAuth is a shared mailbox but im under the impression that the OAuth bypasses all logins to be able to send mail. Testing my own email login on SMTP basic auth gives the same error? as far as i know, smtp is turned on for all accounts. we regularly use this shared box through thunderbird.

Code: Select all

2024-07-09 23:25:07	SMTP ERROR: Password command failed: 535 Incorrect authentication data

Re: microsoft 365 smtp wont authenticate but imap works

Posted: Wed Jul 10, 2024 12:21 pm
by Klemen
Can you create a new user (without any shared mailboxes) and see if that works for you?

Re: microsoft 365 smtp wont authenticate but imap works

Posted: Mon Jul 15, 2024 4:36 pm
by potato
i was able to resolve the issue.

i realized smtp was trying to authenticate locally on my server by tailing the exim logs. i went into WHM > smtp restrictions and disabled it and now it's working.

i also had to convert the mailbox to a regular box instead of shared.

Re: microsoft 365 smtp wont authenticate but imap works

Posted: Tue Jul 16, 2024 10:29 am
by Klemen
Great, thank you for sharing your solution!