From 410e297d0e429243e43d801c588bd489c37b7859 Mon Sep 17 00:00:00 2001 From: Charlie Tonneslan Date: Sat, 16 May 2026 13:21:17 -0400 Subject: [PATCH] allow SMTP without credentials for anonymous relays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 #136 Signed-off-by: Charlie Tonneslan --- main.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index bbb3423..c3c7586 100644 --- a/main.go +++ b/main.go @@ -74,15 +74,20 @@ var rootCmd = &cobra.Command{ Short: "Send emails from your terminal", Long: `Pop is a tool for sending emails from your terminal.`, RunE: func(cmd *cobra.Command, _ []string) error { + // SMTP is "enabled" if the user pointed at a server, with or + // without credentials. Local/relay setups (universities, internal + // mailrelays) often run without auth, see #136. + smtpEnabled := smtpHost != "" || smtpUsername != "" || smtpPassword != "" + var deliveryMethod DeliveryMethod switch { - case resendAPIKey != "" && smtpUsername != "" && smtpPassword != "": + case resendAPIKey != "" && smtpEnabled: deliveryMethod = Unknown case resendAPIKey != "": deliveryMethod = Resend - case smtpUsername != "" && smtpPassword != "": + case smtpEnabled: deliveryMethod = SMTP - if from == "" { + if from == "" && smtpUsername != "" { from = smtpUsername } }