Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/support helo customization #102

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ export [email protected]
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`
Expand Down
1 change: 1 addition & 0 deletions email.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -67,6 +70,7 @@ var (
smtpEncryption string
smtpInsecureSkipVerify bool
resendAPIKey string
smtpHelo string
)

var rootCmd = &cobra.Command{
Expand Down Expand Up @@ -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

Expand Down
Binary file added pop
Binary file not shown.