microsoft 365 smtp wont authenticate but imap works

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
potato
Posts: 3
Joined: Mon Jul 08, 2024 2:46 am

microsoft 365 smtp wont authenticate but imap works

Post 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
Klemen
Site Admin
Posts: 10139
Joined: Fri Feb 11, 2005 4:04 pm

Re: microsoft 365 smtp wont authenticate but imap works

Post 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?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
potato
Posts: 3
Joined: Mon Jul 08, 2024 2:46 am

Re: microsoft 365 smtp wont authenticate but imap works

Post 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
Klemen
Site Admin
Posts: 10139
Joined: Fri Feb 11, 2005 4:04 pm

Re: microsoft 365 smtp wont authenticate but imap works

Post by Klemen »

Can you create a new user (without any shared mailboxes) and see if that works for you?
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
potato
Posts: 3
Joined: Mon Jul 08, 2024 2:46 am

Re: microsoft 365 smtp wont authenticate but imap works

Post 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.
Klemen
Site Admin
Posts: 10139
Joined: Fri Feb 11, 2005 4:04 pm

Re: microsoft 365 smtp wont authenticate but imap works

Post by Klemen »

Great, thank you for sharing your solution!
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Post Reply