From ae9be80510a4264a61b235c1fcf033204a62bf29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Montegaspp=CE=B1=20Cacilh=CE=B1=CF=82?= Date: Wed, 16 Jul 2025 18:02:52 -0300 Subject: [PATCH 1/2] add POP_BCC useful for backup --- main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index a820b78..fb82828 100644 --- a/main.go +++ b/main.go @@ -26,6 +26,7 @@ const ResendAPIKey = "RESEND_API_KEY" //nolint:gosec // PopFrom is the environment variable that sets the default "from" address. const PopFrom = "POP_FROM" +const PopBcc = "POP_BCC" // PopSignature is the environment variable that sets the default signature. const PopSignature = "POP_SIGNATURE" @@ -196,13 +197,12 @@ var ManCmd = &cobra.Command{ func init() { rootCmd.AddCommand(ManCmd) - rootCmd.Flags().StringSliceVar(&bcc, "bcc", []string{}, "BCC recipients") + rootCmd.Flags().StringSliceVar(&bcc, "bcc", []string{os.Getenv(PopBcc)}, "BCC recipients") rootCmd.Flags().StringSliceVar(&cc, "cc", []string{}, "CC recipients") rootCmd.Flags().StringSliceVarP(&attachments, "attach", "a", []string{}, "Email's attachments") rootCmd.Flags().StringSliceVarP(&to, "to", "t", []string{}, "Recipients") rootCmd.Flags().StringVarP(&body, "body", "b", "", "Email's contents") - envFrom := os.Getenv(PopFrom) - rootCmd.Flags().StringVarP(&from, "from", "f", envFrom, "Email's sender"+commentStyle.Render("($"+PopFrom+")")) + rootCmd.Flags().StringVarP(&from, "from", "f", os.Getenv(PopFrom), "Email's sender"+commentStyle.Render("($"+PopFrom+")")) rootCmd.Flags().StringVarP(&subject, "subject", "s", "", "Email's subject") rootCmd.Flags().BoolVar(&preview, "preview", false, "Whether to preview the email before sending") envUnsafe := os.Getenv(PopUnsafeHTML) == "true" From 23595080c3094ab5c2d7181b11f9cff64635e2a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Montegaspp=CE=B1=20Cacilh=CE=B1=CF=82?= Date: Wed, 16 Jul 2025 18:38:00 -0300 Subject: [PATCH 2/2] deal with empty Bcc --- main.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index fb82828..d6abc7e 100644 --- a/main.go +++ b/main.go @@ -197,12 +197,18 @@ var ManCmd = &cobra.Command{ func init() { rootCmd.AddCommand(ManCmd) - rootCmd.Flags().StringSliceVar(&bcc, "bcc", []string{os.Getenv(PopBcc)}, "BCC recipients") + bccValue := make([]string, 0, 1) + envBcc := os.Getenv(PopBcc) + if envBcc != "" { + bccValue = append(bccValue, envBcc) + } + rootCmd.Flags().StringSliceVar(&bcc, "bcc", bccValue, "BCC recipients"+commentStyle.Render("($"+PopBcc+")")) rootCmd.Flags().StringSliceVar(&cc, "cc", []string{}, "CC recipients") rootCmd.Flags().StringSliceVarP(&attachments, "attach", "a", []string{}, "Email's attachments") rootCmd.Flags().StringSliceVarP(&to, "to", "t", []string{}, "Recipients") rootCmd.Flags().StringVarP(&body, "body", "b", "", "Email's contents") - rootCmd.Flags().StringVarP(&from, "from", "f", os.Getenv(PopFrom), "Email's sender"+commentStyle.Render("($"+PopFrom+")")) + envFrom := os.Getenv(PopFrom) + rootCmd.Flags().StringVarP(&from, "from", "f", envFrom, "Email's sender"+commentStyle.Render("($"+PopFrom+")")) rootCmd.Flags().StringVarP(&subject, "subject", "s", "", "Email's subject") rootCmd.Flags().BoolVar(&preview, "preview", false, "Whether to preview the email before sending") envUnsafe := os.Getenv(PopUnsafeHTML) == "true"