Skip to content

allow SMTP without credentials for anonymous relays - #167

Merged
Amolith merged 3 commits into
charmbracelet:mainfrom
c-tonneslan:feat/optional-smtp-credentials
Jul 17, 2026
Merged

allow SMTP without credentials for anonymous relays#167
Amolith merged 3 commits into
charmbracelet:mainfrom
c-tonneslan:feat/optional-smtp-credentials

Conversation

@c-tonneslan

@c-tonneslan c-tonneslan commented May 16, 2026

Copy link
Copy Markdown
Contributor

Closes #136
Supersedes #144

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>

@Amolith Amolith left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for the PR! :) I left one comment, but other than that, and after rebasing on main to resolve the conflicts, looks good to me!

Comment thread main.go Outdated
Amolith added 2 commits July 16, 2026 21:38
Treat SMTP as configured only when a host or username is present. Return
a config error when a password's supplied without a username because
SMTP auth can't use a password on its own.
@Amolith
Amolith merged commit 6a0c5f3 into charmbracelet:main Jul 17, 2026
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

2 participants