dry0106 2019-08-20 22:48
浏览 707

如何设置电子邮件的“ 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?

  • 写回答

1条回答 默认 最新

  • duanchuan6350 2019-08-21 17:36
    关注

    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)
    
    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突