mirror of
https://github.com/astaxie/beego.git
synced 2024-11-25 21:31:30 +00:00
show from when Config from is empty
This commit is contained in:
parent
a80feb00b8
commit
4de91f675d
@ -74,9 +74,6 @@ func NewEMail(config string) *Email {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if e.From == "" {
|
|
||||||
e.From = e.Username
|
|
||||||
}
|
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,13 +225,19 @@ func (e *Email) Send() error {
|
|||||||
to := make([]string, 0, len(e.To)+len(e.Cc)+len(e.Bcc))
|
to := make([]string, 0, len(e.To)+len(e.Cc)+len(e.Bcc))
|
||||||
to = append(append(append(to, e.To...), e.Cc...), e.Bcc...)
|
to = append(append(append(to, e.To...), e.Cc...), e.Bcc...)
|
||||||
// Check to make sure there is at least one recipient and one "From" address
|
// Check to make sure there is at least one recipient and one "From" address
|
||||||
if e.From == "" || len(to) == 0 {
|
if len(to) == 0 {
|
||||||
return errors.New("Must specify at least one From address and one To address")
|
return errors.New("Must specify at least one To address")
|
||||||
}
|
}
|
||||||
|
|
||||||
from, err := mail.ParseAddress(e.Username)
|
from, err := mail.ParseAddress(e.Username)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(e.From) == 0 {
|
||||||
|
e.From = from.String()
|
||||||
|
}
|
||||||
|
|
||||||
raw, err := e.Bytes()
|
raw, err := e.Bytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user