Skip to content

allow SMTP without credentials for anonymous relays#167

Open
c-tonneslan wants to merge 1 commit into
charmbracelet:mainfrom
c-tonneslan:feat/optional-smtp-credentials
Open

allow SMTP without credentials for anonymous relays#167
c-tonneslan wants to merge 1 commit into
charmbracelet:mainfrom
c-tonneslan:feat/optional-smtp-credentials

Conversation

@c-tonneslan

Copy link
Copy Markdown

Closes #136.

SMTP delivery was gated on both `smtpUsername` and `smtpPassword` being non-empty, so you couldn't use pop against an internal mail relay or a university SMTP server that accepts anonymous sends. The underlying `xhit/go-simple-mail` library already does the right thing when `Username` is empty (the auth switch falls through to no-auth at email.go:859), so the gate was the only thing blocking this.

Switched the trigger to "any SMTP setting is set" (`smtpHost` or `smtpUsername` or `smtpPassword`). The from-defaults-to-username step only runs when there's a username to fall back to.

Tested locally with `go build`. No tests in this package yet, didn't add one for the same reason the deliveryMethod logic is inlined in `RunE` and not easily callable in isolation. Happy to break it out into a small helper if you'd like that as a follow-up.

The SMTP delivery method was gated on both smtpUsername and smtpPassword
being non-empty, which meant you couldn't use pop against an internal
mail relay or a university SMTP server that accepts anonymous sends. The
underlying go-simple-mail library already does the right thing when
Username is empty (skips auth in the AUTH switch), so the gate was the
only thing blocking this.

Switch the trigger to "any SMTP setting is set" — host or user or
password. The from-defaults-to-username step only runs when there is a
username to fall back to.

Closes charmbracelet#136

Signed-off-by: Charlie Tonneslan <cst0520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Don't make username and password mandatory for SMTP

1 participant