Contact form: SMTP_FROM=hello@where-woof.com (SES-ready), add Reply-To
This commit is contained in:
@@ -72,6 +72,13 @@ func sendContactEmail(name, email, subject, message string) error {
|
||||
if port == "" {
|
||||
port = "587"
|
||||
}
|
||||
// Sender address on the envelope + From header. Defaults to hello@where-woof.com
|
||||
// (SES verified identity). For Gmail SMTP this is ignored/overridden by the
|
||||
// authenticated user, so it stays safe either way.
|
||||
from := os.Getenv("SMTP_FROM")
|
||||
if from == "" {
|
||||
from = "hello@where-woof.com"
|
||||
}
|
||||
|
||||
subj := subject
|
||||
if subj == "" {
|
||||
@@ -80,7 +87,8 @@ func sendContactEmail(name, email, subject, message string) error {
|
||||
body := fmt.Sprintf("From: %s <%s>\nSubject: %s\n\n%s", name, email, subj, message)
|
||||
|
||||
msg := []byte("To: " + to + "\r\n" +
|
||||
"From: " + user + "\r\n" +
|
||||
"From: " + from + "\r\n" +
|
||||
"Reply-To: " + email + "\r\n" +
|
||||
"Subject: " + subj + "\r\n" +
|
||||
"MIME-Version: 1.0\r\n" +
|
||||
"Content-Type: text/plain; charset=utf-8\r\n" +
|
||||
@@ -88,5 +96,5 @@ func sendContactEmail(name, email, subject, message string) error {
|
||||
|
||||
addr := host + ":" + port
|
||||
auth := smtp.PlainAuth("", user, pass, host)
|
||||
return smtp.SendMail(addr, auth, user, []string{to}, msg)
|
||||
return smtp.SendMail(addr, auth, from, []string{to}, msg)
|
||||
}
|
||||
Reference in New Issue
Block a user