1
0
mirror of https://github.com/astaxie/beego.git synced 2024-12-23 07:10:49 +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")
}
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 {
return err
}
if len(e.From) == 0 {
e.From = e.Username
}
// use mail's RFC 2047 to encode any string
e.Subject = qEncode("utf-8", e.Subject)