go-gomail / gomail

The best way to send emails in Go.
MIT License
4.33k stars 573 forks source link

Gmail SMTP: syntax error #3

Closed ivoviz closed 9 years ago

ivoviz commented 9 years ago

Hey!

Could be me doing something wrong, but whenever I set the From header with FormatAddress function I get panic: 555 5.5.2 Syntax error. u8sm2660708wjq.1 - gsmtp from smtp.gmail.com

If I use the simple msg.SetHeader("From", "whatever@mail.com") format it works.

msg := gomail.NewMessage()
// msg.SetHeader("From", e.SenderMail)) // works
msg.SetHeader("From", msg.FormatAddress(e.SenderEmail, e.SenderName)) // error
msg.SetHeader("To", e.RecieverEmail)
msg.SetHeader("Subject", e.Subject)
msg.SetBody("text/html", e.Body)
mailer := gomail.NewMailer("smtp.gmail.com", "test@gmail.com", "password", 587)
if err := mailer.Send(msg); err != nil {
    panic(err)
}
alexcesaro commented 9 years ago

Thank you, it was a bug. It should work now.