From 37b2e555f689c5879b94a0e0eb7d07876b8372b4 Mon Sep 17 00:00:00 2001 From: MrMelon54 Date: Wed, 23 Aug 2023 19:14:47 +0100 Subject: [PATCH] Use full from address in mail data --- api/send-message.go | 2 +- smtp/json.go | 2 +- smtp/smtp.go | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/api/send-message.go b/api/send-message.go index ac9a765..87e4f8a 100644 --- a/api/send-message.go +++ b/api/send-message.go @@ -41,7 +41,7 @@ func MessageSender(send Smtp) func(rw http.ResponseWriter, req *http.Request, pa } // this looks up the underlying account for the sender alias - lookup, err := defaultPostfixLookup(mail.From) + lookup, err := defaultPostfixLookup(mail.From.Address) // the alias does not exist if errors.Is(err, postfixLookup.ErrInvalidAlias) { diff --git a/smtp/json.go b/smtp/json.go index a8e26c1..4042b11 100644 --- a/smtp/json.go +++ b/smtp/json.go @@ -101,7 +101,7 @@ func (s Json) PrepareMail(now time.Time) (*Mail, error) { } return &Mail{ - From: from.String(), + From: from, Body: out.Bytes(), }, nil } diff --git a/smtp/smtp.go b/smtp/smtp.go index 776ff90..2e84f7e 100644 --- a/smtp/smtp.go +++ b/smtp/smtp.go @@ -1,6 +1,7 @@ package smtp import ( + "github.com/emersion/go-message/mail" "os/exec" ) @@ -9,7 +10,7 @@ type Smtp struct { } type Mail struct { - From string + From *mail.Address Body []byte } @@ -19,7 +20,7 @@ var execSendMail = func(from string) *exec.Cmd { func (s *Smtp) Send(mail *Mail) error { // start sendmail caller - sendMail := execSendMail(mail.From) + sendMail := execSendMail(mail.From.String()) inPipe, err := sendMail.StdinPipe() if err != nil { return err