]> source.dussan.org Git - gitea.git/commitdiff
Parse the from string to extract the email address
authorPeter <peter@smitmail.eu>
Fri, 19 Dec 2014 21:06:03 +0000 (23:06 +0200)
committerPeter <peter@smitmail.eu>
Fri, 19 Dec 2014 21:06:03 +0000 (23:06 +0200)
conf/app.ini
modules/mailer/mailer.go

index d117884676e7ea2cf8c1de41d17962b78dfae22c..4c2d146bbe80d6f7e5a2f310dd97aee9af1f55a5 100644 (file)
@@ -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" <email@example.com> format (including the quotes and brackets)
+; Mail from address, RFC 5322. This can be just an email address, or the "Name" <email@example.com> format 
 FROM =
 ; Mailer user name and password
 USER =
index 3ce14822f70788467af8c0f973b59f285f19d02b..fd10c1e5a9e0480440eb33e66c3bb65efaab369a 100644 (file)
@@ -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 {