From 9a63567b0c4a126d833b0df600e65d3a800e8787 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Wed, 3 Jan 2024 15:46:57 +1300 Subject: [PATCH] Fix: Sendmail support for `-f 'Name '` format --- sendmail/cmd/cmd.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sendmail/cmd/cmd.go b/sendmail/cmd/cmd.go index 44e9501..87c1155 100644 --- a/sendmail/cmd/cmd.go +++ b/sendmail/cmd/cmd.go @@ -157,7 +157,13 @@ func Run() { } } - err = smtp.SendMail(SMTPAddr, nil, FromAddr, addresses, body) + from, err := mail.ParseAddress(FromAddr) + if err != nil { + fmt.Fprintln(os.Stderr, "invalid from address") + os.Exit(11) + } + + err = smtp.SendMail(SMTPAddr, nil, from.Address, addresses, body) if err != nil { fmt.Fprintln(os.Stderr, "error sending mail") logger.Log().Fatal(err)