From 227be27bed100ff8fdb1b9651cb5d6f14ab42390 Mon Sep 17 00:00:00 2001 From: Daniel Lundqvist Date: Wed, 22 Mar 2017 13:48:17 +0100 Subject: [PATCH 1/2] SendTLSMail takes a *tls.Config instead of a tls.Config --- smtp.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/smtp.go b/smtp.go index 9b2ab7d..5506d37 100644 --- a/smtp.go +++ b/smtp.go @@ -1,7 +1,7 @@ package gophermail import ( - "crypto/tls" + "crypto/tls" "net/smtp" ) @@ -31,10 +31,9 @@ func SendMail(addr string, a smtp.Auth, msg *Message) error { return smtp.SendMail(addr, a, msg.From.Address, to, msgBytes) } - // SendTLSMail does the same thing as SendMail, except with the added // option of providing a tls.Config -func SendTLSMail(addr string, a smtp.Auth, msg *Message, cfg tls.Config) error { +func SendTLSMail(addr string, a smtp.Auth, msg *Message, cfg *tls.Config) error { msgBytes, err := msg.Bytes() if err != nil { return err @@ -53,7 +52,7 @@ func SendTLSMail(addr string, a smtp.Auth, msg *Message, cfg tls.Config) error { to = append(to, address.Address) } - from := msg.From.String() + from := msg.From.String() c, err := smtp.Dial(addr) if err != nil { @@ -62,9 +61,9 @@ func SendTLSMail(addr string, a smtp.Auth, msg *Message, cfg tls.Config) error { defer c.Close() if ok, _ := c.Extension("STARTTLS"); ok { - if err = c.StartTLS(&cfg); err != nil { - return err - } + if err = c.StartTLS(cfg); err != nil { + return err + } } if a != nil { From 78038048f573e60064febafe738b8128ff3ce303 Mon Sep 17 00:00:00 2001 From: Xue Si Date: Thu, 23 Mar 2017 10:22:02 +0100 Subject: [PATCH 2/2] use .Address instead of .String to maintain angled brackets to comply with Gmail SMTP implementation --- smtp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smtp.go b/smtp.go index 5506d37..b0c46e8 100644 --- a/smtp.go +++ b/smtp.go @@ -52,7 +52,7 @@ func SendTLSMail(addr string, a smtp.Auth, msg *Message, cfg *tls.Config) error to = append(to, address.Address) } - from := msg.From.String() + from := msg.From.Address c, err := smtp.Dial(addr) if err != nil {