Page 1 of 1
OAuth email setup, IMAP works, SMTP doesn't?
Posted: Thu Mar 13, 2025 2:53 pm
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)
Re: OAuth email setup, IMAP works, SMTP doesn't?
Posted: Thu Mar 13, 2025 6:36 pm
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
Re: OAuth email setup, IMAP works, SMTP doesn't?
Posted: Fri Mar 14, 2025 9:23 am
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
Re: OAuth email setup, IMAP works, SMTP doesn't?
Posted: Fri Mar 14, 2025 3:29 pm
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).
Re: OAuth email setup, IMAP works, SMTP doesn't?
Posted: Sat Mar 22, 2025 9:04 pm
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