binwiederhier / ntfy

Send push notifications to your phone or desktop using PUT/POST
https://ntfy.sh
Apache License 2.0
18.01k stars 700 forks source link

Email authentication fails with Microsoft 365 Outlook SMTP #1020

Open MrChadMWood opened 7 months ago

MrChadMWood commented 7 months ago

:lady_beetle: Describe the bug Email authentication fails with Microsoft 365 Outlook SMTP using STARTTLS encryption,

:computer: Components impacted Server-side

:bulb: Screenshots and/or logs

### smtp-mail.outlook.com:587
{"time":"2024-02-08T22:33:56.559Z","level":"WARN","message":"Unable to send email to cencored@cencored.com: 504 5.7.4 Unrecognized authentication type [CY4PR0501MB3908.namprd05.prod.outlook.com 2024-02-08T22:33:51.710Z 08DC255743C7]","email":"cencored@cencored.com","error":"504 5.7.4 Unrecognized authentication type [CY4PR0501MB3908.namprd05.prod.outlook.com 2024-02-08T22:33:51.710Z 08DC25520C743C70]","message_body_size":9,"message_event":"message","message_id":"4qmF5LaJcSpv","message_sender":"172.25.0.1","message_time":1707431626,"message_user":"u_U5MeBhxJuu","tag":"email","topic":"test-expiry-notifications","user_id":"u_U5MeBhxJuu","user_name":"cwood","visitor_auth_limiter_limit":0.016666666666666666,"visitor_auth_limiter_tokens":30,"visitor_emails":2,"visitor_emails_limit":24,"visitor_emails_remaining":22,"visitor_id":"ip:172.25.0.1","visitor_ip":"172.25.0.1","visitor_messages":2,"visitor_messages_limit":17280,"visitor_messages_remaining":17278,"visitor_request_limiter_limit":0.2,"visitor_request_limiter_tokens":57.056149986399994,"visitor_seen":"2024-02-08T22:33:52.477Z"}

### smtp-legacy.office365.com:587
{"time":"2024-02-08T23:16:18.697Z","level":"WARN","message":"Unable to send email to cencored@cencored.com: 504 5.7.4 Unrecognized authentication type [CY4PR0501.prod.exchangelabs.com 2024-02-08T23:16:13.824Z 08DC27850D59]","email":"cencored@cencored.com","error":"504 5.7.4 Unrecognized authentication type [CY4PR0501.prod.exchangelabs.com 2024-02-08T23:16:13.824Z 08DC278511F0D59E]","message_body_size":9,"message_event":"message","message_id":"H0c2IFiqomiR","message_sender":"172.26.0.1","message_time":1707434168,"message_user":"u_U5MeBhxJuu","tag":"email","topic":"test-expiry-notifications","visitor_auth_limiter_limit":0.016666666666666666,"visitor_auth_limiter_tokens":30,"visitor_emails":1,"visitor_emails_limit":24,"visitor_emails_remaining":23,"visitor_id":"ip:172.26.0.1","visitor_ip":"172.26.0.1","visitor_messages":1,"visitor_messages_limit":17280,"visitor_messages_remaining":17279,"visitor_request_limiter_limit":0.2,"visitor_request_limiter_tokens":60,"visitor_seen":"2024-02-08T23:16:09.983Z"}

At first I attempted to connect as described in Microsofts documentation:

# /etc/ntfy/server.yml

smtp-sender-addr: "smtp-mail.outlook.com:587"
smtp-sender-from: "alias@cencored.com"
smtp-sender-pass: "cencored"
smtp-sender-user: "cencored@cencored.com"

After that, I attempted using the legacy smtp endpoint as documented here. smtp-sender-addr: "smtp-legacy.office365.com:587"

In either case it fails with the errors provided.

:crystal_ball: Additional context Stack Exchange

wunter8 commented 7 months ago

The problem is that ntfy only supports AUTH PLAIN right now, and Microsoft 365 Outlook only supports AUTH LOGIN right now.

If you're so inclined, you can look at the steps here to fix it: https://github.com/binwiederhier/ntfy/issues/930