如何设置电子邮件的“ MAIL FROM”标题?

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?

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 := "bounces@bounce.example.com"
to := []string{"receiver@example.com"}

return s.Send(mailFrom, to, m)