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")
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 机器人轨迹规划相关问题
  • ¥15 word样式右侧翻页键消失
  • ¥15 springboot+vue 集成keycloak sso到阿里云
  • ¥15 win7系统进入桌面过一秒后突然黑屏
  • ¥30 backtrader对于期货交易的现金和资产计算的问题
  • ¥15 求C# .net4.8小报表工具
  • ¥15 安装虚拟机时出现问题
  • ¥15 Selenium+docker Chrome不能运行
  • ¥15 mac电脑,安装charles后无法正常抓包
  • ¥18 visio打开文件一直显示文件未找到