Skip to content

SMTP sender always connects with an "EHLO localhost" rather than "EHLO <actual hostname>" #1602

@konstantint

Description

@konstantint

🐞 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    🪲 bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions