aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2020-12-02 14:41:56 -0800
committerGitHub <noreply@github.com>2020-12-02 14:41:56 -0800
commitc15ad6700b519f1bdb1a1ee7a8ec8ea14f41999c (patch)
tree0b1c155e34098970ae05f2975eb6147e5b5f371e
parenta9d3a1fedd0a69ce42543d5bf5c95ed60c1aa13c (diff)
parentaa20e2d1cdd7bf96dbb0c51373ee7b60c4e8f592 (diff)
downloadses-smtpd-proxy-c15ad6700b519f1bdb1a1ee7a8ec8ea14f41999c.tar.bz2
ses-smtpd-proxy-c15ad6700b519f1bdb1a1ee7a8ec8ea14f41999c.tar.xz
ses-smtpd-proxy-c15ad6700b519f1bdb1a1ee7a8ec8ea14f41999c.zip
Merge pull request #2 from thomasdupas/master
add envelope sender handling; needed for correct bounce processing
-rw-r--r--main.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/main.go b/main.go
index 5de865c..d633368 100644
--- a/main.go
+++ b/main.go
@@ -19,6 +19,7 @@ const (
19var sesClient *ses.SES 19var sesClient *ses.SES
20 20
21type Envelope struct { 21type Envelope struct {
22 from string
22 rcpts []*string 23 rcpts []*string
23 b bytes.Buffer 24 b bytes.Buffer
24} 25}
@@ -50,12 +51,13 @@ func (e *Envelope) logMessageSend() {
50 for i := range e.rcpts { 51 for i := range e.rcpts {
51 dr[i] = *e.rcpts[i] 52 dr[i] = *e.rcpts[i]
52 } 53 }
53 log.Printf("sending message to %+v", dr) 54 log.Printf("sending message from %+v to %+v", e.from, dr)
54} 55}
55 56
56func (e *Envelope) Close() error { 57func (e *Envelope) Close() error {
57 e.logMessageSend() 58 e.logMessageSend()
58 r := &ses.SendRawEmailInput{ 59 r := &ses.SendRawEmailInput{
60 Source: &e.from,
59 Destinations: e.rcpts, 61 Destinations: e.rcpts,
60 RawMessage: &ses.RawMessage{Data: e.b.Bytes()}, 62 RawMessage: &ses.RawMessage{Data: e.b.Bytes()},
61 } 63 }
@@ -80,7 +82,7 @@ func main() {
80 s := &smtpd.Server{ 82 s := &smtpd.Server{
81 Addr: addr, 83 Addr: addr,
82 OnNewMail: func(c smtpd.Connection, from smtpd.MailAddress) (smtpd.Envelope, error) { 84 OnNewMail: func(c smtpd.Connection, from smtpd.MailAddress) (smtpd.Envelope, error) {
83 return &Envelope{}, nil 85 return &Envelope{from: from.Email()}, nil
84 }, 86 },
85 } 87 }
86 log.Printf("ListenAndServe on %s", addr) 88 log.Printf("ListenAndServe on %s", addr)