Closed aletheia7 closed 7 years ago
package main import ( "github.com/go-gomail/gomail" "os" "fmt" "time" ) func main() { fmt.Fprintln(os.Stdout, "Good") m := gomail.NewMessage() m.SetHeader("From", "guy@example.com.com") m.SetHeader("To", "guy@example.com.com") m.SetHeader("Subject", "t1") m.SetBody("text/plain", "Hello!") m.WriteTo(os.Stdout) m.Reset() m.SetHeaders(map[string][]string{ "From": {m.FormatAddress("guy@example.com.com", "Sender")}, "To": {m.FormatAddress("guy@example.com.com", "The Dude")}, "Date": {m.FormatDate(time.Now())}, "Subject:": {"Hello!"}, }) m.SetBody("text/plain", "t1") fmt.Fprintln(os.Stdout, "\nBad") m.WriteTo(os.Stdout) fmt.Println("") }
Good Mime-Version: 1.0 Date: Sat, 05 Aug 2017 20:31:32 -0700 From: guy@example.com.com To: guy@example.com.com Subject: t1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hello! Bad Mime-Version: 1.0 From: "Sender" <guy@example.com.com> To: "The Dude" <guy@example.com.com> Date: Sat, 05 Aug 2017 20:31:32 -0700 Subject:: Hello! Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable t1
Version: 81ebce5c23dfd25c6c67194b37d3dd3f338c98b1
Isn't this just because you put the colon in yourself?
"Subject:": {"Hello!"},
which you did not do in the first version?
Yes. Sorry about that.
Test App
Output
Version: 81ebce5c23dfd25c6c67194b37d3dd3f338c98b1