[GH-ISSUE #1602] SMTP sender always connects with an "EHLO localhost" rather than "EHLO <actual hostname>" #1123

Open
opened 2026-05-07 00:30:26 +02:00 by BreizhHardware · 0 comments

Originally created by @konstantint on GitHub (Feb 10, 2026).
Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1602

🐞 Describe the bug
At the moment it is impossible to send SMTP notifications via, for example, smtp-relay.gmail.com, because that server rejects clients who begin their protocol exchange with an "EHLO localhost" command, but will accept literally any other value. This behaviour comes from the net/smtp library that simply hardcodes "localhost" as the host in the hello command.

The fix is not too complicated, although copy-pasteish. Let me know if you'd like me to make it into a PR. Note that in the example I replaced "localhost" with os.Hostname(), which in theory could break clients that somewhy relied on "localhost" specifically being used in the EHLO command. Perhaps a more gentle update would be to introduce a config setting providing the desired hostname, that defaults to "localhost".

Even if this is a peculiarity of Gmail's relay only, it is probably a large enough of a case to deserve supporting (also maybe there are good reasons for the server to reject "localhost").

💻 Components impacted
ntfy server

💡 Screenshots and/or logs

Image
Originally created by @konstantint on GitHub (Feb 10, 2026). Original GitHub issue: https://github.com/binwiederhier/ntfy/issues/1602 :lady_beetle: **Describe the bug** At the moment it is impossible to send SMTP notifications via, for example, smtp-relay.gmail.com, because that server rejects clients who begin their protocol exchange with an "EHLO localhost" command, but will accept literally any other value. This behaviour comes from the net/smtp library that simply hardcodes "localhost" as the host in the hello command. The fix is [not too complicated](https://github.com/binwiederhier/ntfy/compare/main...konstantint:ntfy:smtp-hello-host-fix), although copy-pasteish. Let me know if you'd like me to make it into a PR. Note that in the example I replaced "localhost" with os.Hostname(), which in theory could break clients that somewhy relied on "localhost" specifically being used in the EHLO command. Perhaps a more gentle update would be to introduce a config setting providing the desired hostname, that defaults to "localhost". Even if this is a peculiarity of Gmail's relay only, it is probably a large enough of a case to deserve supporting (also maybe there are good reasons for the server to reject "localhost"). :computer: **Components impacted** ntfy server :bulb: **Screenshots and/or logs** <img width="1653" height="907" alt="Image" src="https://github.com/user-attachments/assets/287d6ac5-96ec-4367-9400-2baa1883a2b3" />
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/ntfy#1123
No description provided.