Parse the from string to extract the email address
This commit is contained in:
parent
edbe1de026
commit
c884ecfea1
2 changed files with 7 additions and 2 deletions
|
@ -98,7 +98,7 @@ SUBJECT = %(APP_NAME)s
|
||||||
HOST =
|
HOST =
|
||||||
; Do not verify the certificate of the server. Only use this for self-signed certificates
|
; Do not verify the certificate of the server. Only use this for self-signed certificates
|
||||||
SKIP_VERIFY =
|
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 =
|
FROM =
|
||||||
; Mailer user name and password
|
; Mailer user name and password
|
||||||
USER =
|
USER =
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"net/mail"
|
||||||
"net/smtp"
|
"net/smtp"
|
||||||
"strings"
|
"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
|
return err
|
||||||
|
} else {
|
||||||
|
if err = client.Mail(fromAddress.Address); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rec := range recipients {
|
for _, rec := range recipients {
|
||||||
|
|
Loading…
Reference in a new issue