From: Peter Date: Fri, 19 Dec 2014 21:06:03 +0000 (+0200) Subject: Parse the from string to extract the email address X-Git-Tag: v0.9.99~1565^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c884ecfea18b001ceb9cdbe98c8618a345f460e0;p=gitea.git Parse the from string to extract the email address --- diff --git a/conf/app.ini b/conf/app.ini index d117884676..4c2d146bbe 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -98,7 +98,7 @@ SUBJECT = %(APP_NAME)s HOST = ; Do not verify the certificate of the server. Only use this for self-signed certificates SKIP_VERIFY = -; Mail from address. This can be just an email address, or the "Name" format (including the quotes and brackets) +; Mail from address, RFC 5322. This can be just an email address, or the "Name" format FROM = ; Mailer user name and password USER = diff --git a/modules/mailer/mailer.go b/modules/mailer/mailer.go index 3ce14822f7..fd10c1e5a9 100644 --- a/modules/mailer/mailer.go +++ b/modules/mailer/mailer.go @@ -8,6 +8,7 @@ import ( "crypto/tls" "fmt" "net" + "net/mail" "net/smtp" "strings" @@ -124,8 +125,12 @@ func sendMail(settings *setting.Mailer, recipients []string, msgContent []byte) } } - if err = client.Mail(settings.From); err != nil { + if fromAddress, err := mail.ParseAddress(settings.From); err != nil { return err + } else { + if err = client.Mail(fromAddress.Address); err != nil { + return err + } } for _, rec := range recipients {