1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-29 11:11:33 +00:00

Merge pull request #2184 from rahal/master

Emailer : Should use config Username only if no From is provided.
This commit is contained in:
astaxie 2016-09-28 07:56:12 +08:00 committed by GitHub
commit bba04dd864

View File

@ -232,14 +232,16 @@ func (e *Email) Send() error {
return errors.New("Must specify at least one To address") return errors.New("Must specify at least one To address")
} }
from, err := mail.ParseAddress(e.Username) // Use the username if no From is provided
if len(e.From) == 0 {
e.From = e.Username
}
from, err := mail.ParseAddress(e.From)
if err != nil { if err != nil {
return err return err
} }
if len(e.From) == 0 {
e.From = e.Username
}
// use mail's RFC 2047 to encode any string // use mail's RFC 2047 to encode any string
e.Subject = qEncode("utf-8", e.Subject) e.Subject = qEncode("utf-8", e.Subject)