Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions smtp.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package gophermail

import (
"crypto/tls"
"crypto/tls"
"net/smtp"
)

Expand Down Expand Up @@ -31,7 +31,6 @@ 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 {
Expand All @@ -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.Address

c, err := smtp.Dial(addr)
if err != nil {
Expand All @@ -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 {
Expand Down