diff --git a/README.md b/README.md index e5eb04a..fecdb7b 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,19 @@ export POP_SMTP_USERNAME=pop@charm.sh export POP_SMTP_PASSWORD=hunter2 ``` +#### Custom HELO + +> **Note**: +> [Some SMTP relays](https://support.google.com/a/answer/2956491?hl=en&fl=1&sjid=11501593087205020993-NA) does not support `localhost` in the HELO CMD (which is the default pop behavior). + +To configure HELO value, you can set the following environment variables. + +``` +export POP_SMTP_HELO=charm.sh +``` + +Or via the cli `pop -c charm.sh`|`pop --smtp.helo charm.sh` + ### Environment To avoid typing your `From: ` email address, you can also set the `POP_FROM` diff --git a/email.go b/email.go index 3b4efb2..0ef82f3 100644 --- a/email.go +++ b/email.go @@ -71,6 +71,7 @@ func sendSMTPEmail(to, cc, bcc []string, from, subject, body string, attachments server.Password = smtpPassword server.Host = smtpHost server.Port = smtpPort + server.Helo = smtpHelo // Set defaults for gmail. if strings.HasSuffix(server.Username, gmailSuffix) { diff --git a/main.go b/main.go index 00c7bc7..6eca6f1 100644 --- a/main.go +++ b/main.go @@ -45,6 +45,9 @@ const PopSMTPPassword = "POP_SMTP_PASSWORD" //nolint:gosec // PopSMTPEncryption is the encryption type for the SMTP server if the user is using the SMTP delivery method. const PopSMTPEncryption = "POP_SMTP_ENCRYPTION" //nolint:gosec +// PopSMTPHelo is the HELO sent to the SMTP server if the user is using the SMTP delivery method. +const PopSMTPHelo = "POP_SMTP_HELO" + // PopSMTPInsecureSkipVerify is whether or not to skip TLS verification for the // SMTP server if the user is using the SMTP delivery method. const PopSMTPInsecureSkipVerify = "POP_SMTP_INSECURE_SKIP_VERIFY" @@ -67,6 +70,7 @@ var ( smtpEncryption string smtpInsecureSkipVerify bool resendAPIKey string + smtpHelo string ) var rootCmd = &cobra.Command{ @@ -226,6 +230,8 @@ func init() { rootCmd.Flags().BoolVarP(&smtpInsecureSkipVerify, "smtp.insecure", "i", envInsecureSkipVerify, "Skip TLS verification with SMTP server"+commentStyle.Render("($"+PopSMTPInsecureSkipVerify+")")) envResendAPIKey := os.Getenv(ResendAPIKey) rootCmd.Flags().StringVarP(&resendAPIKey, "resend.key", "r", envResendAPIKey, "API key for the Resend.com"+commentStyle.Render("($"+ResendAPIKey+")")) + envSMTPHelo := os.Getenv(PopSMTPHelo) + rootCmd.Flags().StringVarP(&smtpHelo, "smtp.helo", "c", envSMTPHelo, "Helo sent to the SMTP server"+commentStyle.Render("($"+PopSMTPHelo+")")) rootCmd.CompletionOptions.HiddenDefaultCmd = true diff --git a/pop b/pop new file mode 100755 index 0000000..0e091f3 Binary files /dev/null and b/pop differ