diff --git a/handlers.go b/handlers.go index c50d94a..bf2ac7b 100644 --- a/handlers.go +++ b/handlers.go @@ -15,6 +15,7 @@ import ( type postback struct { Subject string `json:"subject"` + FromEmail string `json:"from_email"` ContentType string `json:"content_type"` Body string `json:"body"` Recipients []recipient `json:"recipients"` @@ -86,6 +87,7 @@ func handlePostback(w http.ResponseWriter, r *http.Request) { rec := data.Recipients[0] message := messenger.Message{ + From: data.FromEmail, Subject: data.Subject, ContentType: data.ContentType, Body: []byte(data.Body), diff --git a/messenger/ses.go b/messenger/ses.go index 672fe6f..b18db7a 100644 --- a/messenger/ses.go +++ b/messenger/ses.go @@ -52,8 +52,13 @@ func (s sesMessenger) Push(msg Message) error { } } + fromEmail := msg.From + if msg.Campaign != nil { + fromEmail = msg.Campaign.FromEmail + } + email := smtppool.Email{ - From: msg.Campaign.FromEmail, + From: fromEmail, To: []string{msg.Subscriber.Email}, Subject: msg.Subject, Sender: msg.From,