OAuth email setup, IMAP works, SMTP doesn't?

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
dreamscape
Posts: 2
Joined: Thu Mar 13, 2025 2:40 pm

OAuth email setup, IMAP works, SMTP doesn't?

Post by dreamscape »

HESK version 3.5.3
PHP version 8.2.3 (MySQLi)
MySQL version 8.0.41

Hi All,

Been using OAuth for fetching emails (IMAP) for over a year, I have tried to change SMTP to use OAuth today and get a 5.7.3 error, basic auth works fine.

Please can someone help me spot where I'm going wrong?

Thanks.

(removed)
Klemen
Site Admin
Posts: 10139
Joined: Fri Feb 11, 2005 4:04 pm

Re: OAuth email setup, IMAP works, SMTP doesn't?

Post by Klemen »

It's a mystery. Really.

We've had users with no problems and users with the exact same settings who can't get SMTP to work via OAuth. But, like in your case, basic authorization works fine.

I've spent countless hours reading articles online trying to figure this out and have seen many users with the same problem with non-Hesk related software.

My recommendation is to keep SMTP in Basic auth and forget about it.

The alternative is to search Google for phrases like "Outlook 365 SMTP works with Basic authentication but not with OAuth" and see if you can find something that helps in your case.


P.s.: I removed your log as it doesn't give any useful info; you can try reaching out to Microsoft 365 support with the exact SMTP error log, but don't expect much
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
dreamscape
Posts: 2
Joined: Thu Mar 13, 2025 2:40 pm

Re: OAuth email setup, IMAP works, SMTP doesn't?

Post by dreamscape »

Hi Klemen,

Thanks for getting back to me, unfortunately MS are pulling it in September so remaining with Basic isn't an option....

https://techcommunity.microsoft.com/blo ... th/4114750
Klemen
Site Admin
Posts: 10139
Joined: Fri Feb 11, 2005 4:04 pm

Re: OAuth email setup, IMAP works, SMTP doesn't?

Post by Klemen »

Hmm, thanks for the heads-up. I wasn't aware of the September pull.

If you (or someone else with the exact same problem) is willing to give me admin access to your Microsoft 365 to try to debug this feel free to send me a private message (it works well in my M365 so can't reproduce the issue there).
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
Klemen
Site Admin
Posts: 10139
Joined: Fri Feb 11, 2005 4:04 pm

Re: OAuth email setup, IMAP works, SMTP doesn't?

Post by Klemen »

For anyone else having the same problem - the issue was their Oauth credentials didn't match the email address they were using.

To prevent this from happening, the trick is to use Incognito (Private) browser mode when setting up OAuth. This makes sure you aren't logged in one Microsoft account while setting permissions for another one.

So, if you have the same problem:
1. open a new PRIVATE/INCOGNITO browser window (to make sure you are not logged in anywhere)
2. login to to Hesk admin panel > Tools > OAuth Providers
3. click the "Edit" icon for your OAuth provider
4. click "Save" and you will be redirected to Microsoft
5. make 100% sure you login with the email account you are using in Hesk to send emails into Microsoft
6. when you get back to Hesk, go to Settings > Email and test the SMTP connection again
7. save changes
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