🐛 Bug Report: SMTP fails to authenticate #323

Closed
opened 2025-10-07 00:10:29 +03:00 by OVERLORD · 14 comments
Owner

Originally created by @reddwarf666 on GitHub.

Reproduction steps

Configure the SMTP settings to send emails and then press the "send test email" button.
Specific configuration I faced issues with:

Image

Expected behavior

I expected the test email to be sent and arriving in my inbox

Actual Behavior

I got no email sent but have an entry in the logfile:

Error #01: failed to connect to SMTP server: failed to authenticate SMTP client: 504 5.7.4 
Unrecognized authentication type [AM0PR10CA0128.EURPRD10.PROD.OUTLOOK.COM 
2025-02-28T20:52:53.443Z 08DD571CFA2544C5]

Version and Environment

Pocket-id version : 0.35.3

I tried to connect with smtp.office365.com in a terminal and I could connect without issues:

openssl s_client -connect SMTP.office365.com:587 -starttls smtp -quiet -crlf
EHLO SMTP.office365.com
AUTH LOGIN
<sent user and password as base64 encoded strings>
235 2.7.0 Authentication successful

I tried to connect to the bash terminal in the docker container of pocket-id but could not get that to work or else I would have tested from inside the container.

Log Output

Error #01: failed to connect to SMTP server: failed to authenticate SMTP client: 504 5.7.4 Unrecognized authentication type [AM0PR10CA0128.EURPRD10.PROD.OUTLOOK.COM 2025-02-28T20:52:53.443Z 08DD571CFA2544C5]

Originally created by @reddwarf666 on GitHub. ### Reproduction steps Configure the SMTP settings to send emails and then press the "send test email" button. Specific configuration I faced issues with: <img width="1206" alt="Image" src="https://github.com/user-attachments/assets/34be312f-62c1-4222-a75c-99f700e0f61a" /> ### Expected behavior I expected the test email to be sent and arriving in my inbox ### Actual Behavior I got no email sent but have an entry in the logfile: ``` Error #01: failed to connect to SMTP server: failed to authenticate SMTP client: 504 5.7.4 Unrecognized authentication type [AM0PR10CA0128.EURPRD10.PROD.OUTLOOK.COM 2025-02-28T20:52:53.443Z 08DD571CFA2544C5] ``` ### Version and Environment Pocket-id version : 0.35.3 I tried to connect with smtp.office365.com in a terminal and I could connect without issues: ``` openssl s_client -connect SMTP.office365.com:587 -starttls smtp -quiet -crlf EHLO SMTP.office365.com AUTH LOGIN <sent user and password as base64 encoded strings> 235 2.7.0 Authentication successful ``` I tried to connect to the bash terminal in the docker container of pocket-id but could not get that to work or else I would have tested from inside the container. ### Log Output Error #01: failed to connect to SMTP server: failed to authenticate SMTP client: 504 5.7.4 Unrecognized authentication type [AM0PR10CA0128.EURPRD10.PROD.OUTLOOK.COM 2025-02-28T20:52:53.443Z 08DD571CFA2544C5]
OVERLORD added the bug label 2025-10-07 00:10:29 +03:00
Author
Owner

@kmendell commented on GitHub:

Is the password your using a 'App Password'? or your actual outlook password?

@kmendell commented on GitHub: Is the password your using a 'App Password'? or your actual outlook password?
Author
Owner

@reddwarf666 commented on GitHub:

I just tried that server smtp-mail.outlook.com and got the same error in the pocket-id log:

Error #01: failed to connect to SMTP server: failed to authenticate SMTP client: 504 5.7.4 Unrecognized authentication type [AS4P192CA0018.EURP192.PROD.OUTLOOK.COM 2025-02-28T22:00:52.704Z 08DD583D79577268]

I don't think this is the correct serer address tbh and I can connect and authenticate with smtp.office365.com and it is also used in other apps for sending email and that also works fine. THis seems to be something with either the SMTP fiunctionality in Pocket-id or something on my end or something inside the container.

It's not like it cannot reach the smtp.office365.com server, it fails to authenticate so it should be something else...

@reddwarf666 commented on GitHub: I just tried that server `smtp-mail.outlook.com` and got the same error in the pocket-id log: Error #01: failed to connect to SMTP server: failed to authenticate SMTP client: 504 5.7.4 Unrecognized authentication type [AS4P192CA0018.EURP192.PROD.OUTLOOK.COM 2025-02-28T22:00:52.704Z 08DD583D79577268] I don't think this is the correct serer address tbh and I can connect and authenticate with `smtp.office365.com` and it is also used in other apps for sending email and that also works fine. THis seems to be something with either the SMTP fiunctionality in Pocket-id or something on my end or something inside the container. It's not like it cannot reach the `smtp.office365.com` server, it fails to authenticate so it should be something else...
Author
Owner

@savely-krasovsky commented on GitHub:

Did you try smtp-mail.outlook.com?
Source: https://support.microsoft.com/en-us/office/pop-imap-and-smtp-settings-for-outlook-com-d088b986-291d-42b8-9564-9c414e2aa040

Though it's strange anyway. I tried both STARTTLS (587) and TLS (465) with Fastmail, both worked.

@savely-krasovsky commented on GitHub: Did you try `smtp-mail.outlook.com`? Source: https://support.microsoft.com/en-us/office/pop-imap-and-smtp-settings-for-outlook-com-d088b986-291d-42b8-9564-9c414e2aa040 Though it's strange anyway. I tried both STARTTLS (587) and TLS (465) with Fastmail, both worked.
Author
Owner

@savely-krasovsky commented on GitHub:

To be honest I think they support only OAuth2 and Modern Auth. I think Golang SMTP auth ask server what types of auth it supports and only then tries to auth. It explains why you can auth manually by sending plain AUTH LOGIN command.

@savely-krasovsky commented on GitHub: To be honest I think they support only OAuth2 and Modern Auth. I think Golang SMTP auth ask server what types of auth it supports and only then tries to auth. It explains why you can auth manually by sending plain `AUTH LOGIN` command.
Author
Owner

@reddwarf666 commented on GitHub:

It is using a real password. Not sure if outlook is the thing here but I am not super confident to tell you otherwise.
I use the smtp.office365.com server and I think that is the right one, I use it in other docker containers to send email.

@reddwarf666 commented on GitHub: It is using a real password. Not sure if outlook is the thing here but I am not super confident to tell you otherwise. I use the `smtp.office365.com` server and I think that is the right one, I use it in other docker containers to send email.
Author
Owner

@reddwarf666 commented on GitHub:

Hi

Just tried by

  • copying my pocket-id folder to a new one called pocket-id-test
  • shut down the pocket-id container I had running
  • changed my compose file in pocket-id-test to use image ghcr.io/pocket-id/pocket-id:development-go-smtp
  • started that pocket-id-test container
  • logging in as admin
  • test the email/SMTP functionality by sending test email

The reponses I got in the logs of pocket-id-test:

Error #01: failed to connect to SMTP server: failed to authenticate: SMTP error 504: Unrecognized authentication type [AM0PR03CA0048.eurprd03.prod.outlook.com 2025-03-01T20:40:04.126Z 08DD58ADAA77B1F4]
[GIN] 2025/03/01 - 20:40:04 | 500 |   5.22636374s |   192.168.2.254 | POST     "/api/application-configuration/test-email"
Error #01: failed to connect to SMTP server: failed to authenticate: SMTP error 504: Unrecognized authentication type [AM0PR03CA0048.eurprd03.prod.outlook.com 2025-03-01T20:40:04.126Z 08DD58ADAA77B1F4]

Let me know if I did not use the new image as intended and I will adapt. And if any other testing is needed, feel free to ask!

EDIT: Microsoft is facing authentication issues across multiple services it seems, so testing is going to be hard. Who knows, maybe me testing SMTP authentication brought MS to it's knees? 😂

@reddwarf666 commented on GitHub: Hi Just tried by - copying my pocket-id folder to a new one called pocket-id-test - shut down the pocket-id container I had running - changed my compose file in pocket-id-test to use image `ghcr.io/pocket-id/pocket-id:development-go-smtp` - started that pocket-id-test container - logging in as admin - test the email/SMTP functionality by sending test email The reponses I got in the logs of pocket-id-test: ``` Error #01: failed to connect to SMTP server: failed to authenticate: SMTP error 504: Unrecognized authentication type [AM0PR03CA0048.eurprd03.prod.outlook.com 2025-03-01T20:40:04.126Z 08DD58ADAA77B1F4] [GIN] 2025/03/01 - 20:40:04 | 500 | 5.22636374s | 192.168.2.254 | POST "/api/application-configuration/test-email" Error #01: failed to connect to SMTP server: failed to authenticate: SMTP error 504: Unrecognized authentication type [AM0PR03CA0048.eurprd03.prod.outlook.com 2025-03-01T20:40:04.126Z 08DD58ADAA77B1F4] ``` Let me know if I did not use the new image as intended and I will adapt. And if any other testing is needed, feel free to ask! EDIT: Microsoft is facing authentication issues across multiple services it seems, so testing is going to be hard. Who knows, maybe me testing SMTP authentication brought MS to it's knees? 😂
Author
Owner

@stonith404 commented on GitHub:

I've created a branch where I replaced net/smtp with github.com/emersion/go-smtp which supports the LOGIN auth method. Would you mind to test the ghcr.io/pocket-id/pocket-id:development-go-smtp image and let me know if this fixes your issue?

@stonith404 commented on GitHub: I've created a branch where I replaced `net/smtp` with `github.com/emersion/go-smtp` which supports the `LOGIN` auth method. Would you mind to test the `ghcr.io/pocket-id/pocket-id:development-go-smtp` image and let me know if this fixes your issue?
Author
Owner

@stonith404 commented on GitHub:

There was a problem with the refactor to the new library. Could you test the image again?

EDIT: Microsoft is facing authentication issues across multiple services it seems, so testing is going to be hard. Who knows, maybe me testing SMTP authentication brought MS to it's knees? 😂

Strange 😅

@stonith404 commented on GitHub: There was a problem with the refactor to the new library. Could you test the image again? > EDIT: Microsoft is facing authentication issues across multiple services it seems, so testing is going to be hard. Who knows, maybe me testing SMTP authentication brought MS to it's knees? 😂 Strange 😅
Author
Owner

@kmendell commented on GitHub:

the both resolve to the same thing i think. I do think the plainauth is causing the issue, i tested and confirmed i got the same thing.

@kmendell commented on GitHub: the both resolve to the same thing i think. I do think the plainauth is causing the issue, i tested and confirmed i got the same thing.
Author
Owner

@kmendell commented on GitHub:

@stonith404 I think we may need to look into go-smtp based on the readme, the built in golang net/smtp is frozen and isnt getting features. Or this gist seems to provide workaround functionality to get 'login' nd 'xoauth' auth methods to work. https://gist.github.com/andelf/5118732

Another helpful link: https://stackoverflow.com/questions/57783841/how-to-send-email-using-outlooks-smtp-servers

@kmendell commented on GitHub: @stonith404 I think we may need to look into [go-smtp](https://github.com/emersion/go-smtp) based on the readme, the built in golang net/smtp is frozen and isnt getting features. Or this gist seems to provide workaround functionality to get 'login' nd 'xoauth' auth methods to work. https://gist.github.com/andelf/5118732 Another helpful link: https://stackoverflow.com/questions/57783841/how-to-send-email-using-outlooks-smtp-servers
Author
Owner

@reddwarf666 commented on GitHub:

Me again!

It worked! No idea why pocket-id could authenticate when I can't even get Outlook to do that but here we are.
I sent the test mail and it arrived, so something is working 😀

From the logs:

[GIN] 2025/03/01 - 21:46:01 | 204 | 11.331027895s |   192.168.2.254 | POST     "/api/application-configuration/test-email"

[GIN] 2025/03/01 - 21:46:01 | 204 | 11.331284731s |   192.168.2.254 | POST     "/api/application-configuration/test-email"

EDIT: just realised this makes no sense, Outlook wise, as why did I recieve that test email?
Anyway, your end of the functionality seems fine now! Thanks!

@reddwarf666 commented on GitHub: Me again! It worked! No idea why pocket-id could authenticate when I can't even get Outlook to do that but here we are. I sent the test mail and it arrived, so something is working 😀 From the logs: ``` [GIN] 2025/03/01 - 21:46:01 | 204 | 11.331027895s | 192.168.2.254 | POST "/api/application-configuration/test-email" [GIN] 2025/03/01 - 21:46:01 | 204 | 11.331284731s | 192.168.2.254 | POST "/api/application-configuration/test-email" ``` EDIT: just realised this makes no sense, Outlook wise, as why did I recieve that test email? Anyway, your end of the functionality seems fine now! Thanks!
Author
Owner

@reddwarf666 commented on GitHub:

Tried it and got this in the logs:

Error #01: failed to connect to SMTP server: failed to authenticate: SMTP error 504: Unrecognized authentication type [AS4PR10CA0016.EURPRD10.PROD.OUTLOOK.COM 2025-03-01T21:39:55.693Z 08DD58BEE9E4A7F3]
[GIN] 2025/03/01 - 21:39:55 | 500 |  5.194213437s |   192.168.2.254 | POST     "/api/application-configuration/test-email"

Error #01: failed to connect to SMTP server: failed to authenticate: SMTP error 504: Unrecognized authentication type [AS4PR10CA0016.EURPRD10.PROD.OUTLOOK.COM 2025-03-01T21:39:55.693Z 08DD58BEE9E4A7F3]

But I'm having a tough time atm with Microsoft and Exchange and authenticating even Outlook, so I guess there is some issue on their end and that makes testing a bit unreliable. Anyway, if you have something to test once more then I'm here.
Odd thing is, on my mobile I could re-authenticate all accounts but on my macbook it seems to be problematic.

Hold on, I made a mistake by not pulling the new image, doh...
One moment please...

@reddwarf666 commented on GitHub: Tried it and got this in the logs: ``` Error #01: failed to connect to SMTP server: failed to authenticate: SMTP error 504: Unrecognized authentication type [AS4PR10CA0016.EURPRD10.PROD.OUTLOOK.COM 2025-03-01T21:39:55.693Z 08DD58BEE9E4A7F3] [GIN] 2025/03/01 - 21:39:55 | 500 | 5.194213437s | 192.168.2.254 | POST "/api/application-configuration/test-email" Error #01: failed to connect to SMTP server: failed to authenticate: SMTP error 504: Unrecognized authentication type [AS4PR10CA0016.EURPRD10.PROD.OUTLOOK.COM 2025-03-01T21:39:55.693Z 08DD58BEE9E4A7F3] ``` But I'm having a tough time atm with Microsoft and Exchange and authenticating even Outlook, so I guess there is some issue on their end and that makes testing a bit unreliable. Anyway, if you have something to test once more then I'm here. Odd thing is, on my mobile I could re-authenticate all accounts but on my macbook it seems to be problematic. Hold on, I made a mistake by not pulling the new image, doh... One moment please...
Author
Owner

@stonith404 commented on GitHub:

Alright, thanks for the feedback. I'll release this ASAP.

@stonith404 commented on GitHub: Alright, thanks for the feedback. I'll release this ASAP.
Author
Owner

@reddwarf666 commented on GitHub:

Ok, it seems I was having some issues with licenses. I re-activated and all seems to be good again!

Again, I want to thank you guys for the speed responding and fixing it. Will wait to see when this is propagated to the normal docker images and start using this proper!

@reddwarf666 commented on GitHub: Ok, it seems I was having some issues with licenses. I re-activated and all seems to be good again! Again, I want to thank you guys for the speed responding and fixing it. Will wait to see when this is propagated to the normal docker images and start using this proper!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/pocket-id#323