Reputation: 8565
In the SparkPost (an email sending provider) documentation for setting "bounce domains" it says
specified in the [...] mail from header in the SMTP payload
https://www.sparkpost.com/docs/tech-resources/custom-bounce-domain/
But when I set the "MAIL FROM" header I get a response from their server stating
550 5.6.0 Invalid header found (see RFC2822 section 3.6)
I'm using the plugin gomail "gopkg.in/gomail.v2"
What does setting the "MAIL FROM" header actually mean? How do I set it?
Upvotes: 0
Views: 1656
Reputation: 5119
In my case, I got the same error:
550 5.6.0 Invalid header found (see RFC2822 section 3.6)
After a bit of trial and error, I found that it was not an invalid header, but it was because the Subject:
header was missing. Adding a subject solved the problem.
Upvotes: 0
Reputation: 8565
So it's not a header in the email, maybe their documentation says that incorrectly.
But it's one of the commands sent to the SMTP server when sending the email to the server. This is all handled in gomail
, which uses the net/smtp
package's Mail()
function.
Instead of using
return dialer.DialAndSend(m)
you can call the Send()
function directly on the message, and pass to it a different address.
s, err := dialer.Dial()
if err != nil {
return err
}
defer s.Close()
m := gomail.NewMessage()
mailFrom := "[email protected]"
to := []string{"[email protected]"}
return s.Send(mailFrom, to, m)
Upvotes: 0