Skip to content

Commit

Permalink
fix: use flags
Browse files Browse the repository at this point in the history
  • Loading branch information
maaslalani committed Jul 26, 2023
1 parent f68de59 commit c896905
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions email.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"errors"
"os"
"path/filepath"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -63,10 +62,10 @@ func sendSMTPEmail(to, cc, bcc []string, from, subject, body string, attachments
server := mail.NewSMTPClient()

var err error
server.Username = os.Getenv(PopSMTPUsername)
server.Password = os.Getenv(PopSMTPPassword)
server.Host = os.Getenv(PopSMTPHost)
server.Port, _ = strconv.Atoi(os.Getenv(PopSMTPPort))
server.Username = smtpUsername
server.Password = smtpPassword
server.Host = smtpHost
server.Port = smtpPort

// Set defaults for gmail.
if strings.HasSuffix(server.Username, gmailSuffix) {
Expand All @@ -83,7 +82,7 @@ func sendSMTPEmail(to, cc, bcc []string, from, subject, body string, attachments
server.ConnectTimeout = 10 * time.Second
server.SendTimeout = 10 * time.Second
server.TLSConfig = &tls.Config{
InsecureSkipVerify: os.Getenv(PopSMTPInsecureSkipVerify) == "true", //nolint:gosec
InsecureSkipVerify: smtpInsecureSkipVerify, //nolint:gosec
ServerName: server.Host,
}

Expand Down Expand Up @@ -120,7 +119,7 @@ func sendSMTPEmail(to, cc, bcc []string, from, subject, body string, attachments
}

func sendResendEmail(to, cc, bcc []string, from, subject, body string, attachments []string) error {
client := resend.NewClient(os.Getenv(ResendAPIKey))
client := resend.NewClient(resendAPIKey)

html := bytes.NewBufferString("")
// If the conversion fails, we'll simply send the plain-text body.
Expand Down

0 comments on commit c896905

Please sign in to comment.