drcx71276 2017-10-10 05:01
浏览 109
已采纳

如何使用gomail设置回复电子邮件地址

I am trying to send email using gomail, need to set reply-to email address. Searched a lot but did not get any relevant link.

package main

import "gopkg.in/gomail.v2"

func main() {
   m := gomail.NewMessage()
   m.SetAddressHeader("From", "sender@example.com", "Sandy Sender")
   m.SetAddressHeader("To", "recipient@example.com")
   m.SetHeader("Subject", "Hello!")
   m.SetBody("text/plain", "This is the body of the message.")

   d := gomail.NewPlainDialer("smtp.example.com", 587, "user", "123456")

   if err := d.DialAndSend(m); err != nil {
    panic(err)
    }
}
  • 写回答

1条回答 默认 最新

  • doushou8299 2017-10-10 05:57
    关注

    You can set the Reply-To header for that effect:

    m.SetAddressHeader("Reply-To", "noreply@example.com")
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样