How to set reply-to email address using gomail

1.6k Views Asked by At

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", "[email protected]", "Sandy Sender")
   m.SetAddressHeader("To", "[email protected]")
   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

There are 1 best solutions below

0
janos On BEST ANSWER

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

m.SetAddressHeader("Reply-To", "[email protected]")