From c8969053de5fa4a2cbc9baca03146c44fef96420 Mon Sep 17 00:00:00 2001 From: Maas Lalani Date: Wed, 26 Jul 2023 14:52:17 -0400 Subject: [PATCH] fix: use flags --- email.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/email.go b/email.go index 5ca57dc..b00e5f2 100644 --- a/email.go +++ b/email.go @@ -6,7 +6,6 @@ import ( "errors" "os" "path/filepath" - "strconv" "strings" "time" @@ -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) { @@ -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, } @@ -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.