allow SMTP without credentials for anonymous relays#167
Open
c-tonneslan wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.