diff --git a/sender/sender.go b/sender/sender.go index 679e549f210fafa71cd177f02e441197766a230d..b8e935128694d8046413d408fd3b70a7ce61d230 100644 --- a/sender/sender.go +++ b/sender/sender.go @@ -41,11 +41,18 @@ func SendEmail(cfg *config.Config, to []string, subject, body string) error { // Set up authentication information. auth := smtp.PlainAuth("", cfg.Email, cfg.Password, smtpServer) + // Format the From header to include the sender's name. + fromHeader := cfg.Email + if cfg.Name != "" { + fromHeader = fmt.Sprintf("%s <%s>", cfg.Name, cfg.Email) + } + // Construct the full email message with proper headers. headers := map[string]string{ - "From": cfg.Email, + "From": fromHeader, "To": to[0], // Assuming one recipient for the header display "Subject": subject, + "Date": time.Now().Format(time.RFC1123Z), "Message-ID": generateMessageID(cfg.Email), "Content-Type": "text/plain; charset=UTF-8", // Explicitly set content type } @@ -62,4 +69,4 @@ func SendEmail(cfg *config.Config, to []string, subject, body string) error { // Send the email. err := smtp.SendMail(addr, auth, cfg.Email, to, []byte(msg)) return err -} +} \ No newline at end of file