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

时间:2017-10-10 05:01:08

标签: go gomail

我正在尝试使用gomail发送电子邮件,需要设置回复电子邮件地址。搜索了很多,但没有得到任何相关的链接。

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 个答案:

答案 0 :(得分:2)

您可以为该效果设置Reply-To标题:

m.SetAddressHeader("Reply-To", "noreply@example.com")
相关问题