go-gomail / gomail

The best way to send emails in Go.
MIT License
4.33k stars 573 forks source link

Invalid Date: header (not RFC 2822) #21

Closed OVYA closed 9 years ago

OVYA commented 9 years ago

Hello, SpamAssassin report an invalid date header with mail sent with Gomail because it's not RFC 2822. It is currently set to time.RFC822Z : https://github.com/go-gomail/gomail/blob/master/gomail.go#L147 See https://wiki.apache.org/spamassassin/Rules/INVALID_DATE

Regards

alexcesaro commented 9 years ago

time.RFC822Z is a valid format for date headers: https://tools.ietf.org/html/rfc5322#section-3.3 It is probably the most widely used format for date headers: most emails in my inbox use this format (Gmail, Github, etc) and I found that clients often have issues with the timezone when using the time.RFC822 format.

Do you have an example of an invalid header? Maybe it is caused by a zero value time.Time.

OVYA commented 9 years ago

Sorry, the problem does not seem to come from your library… In my Debian OS the shell command date --rfc-822 outputs "Fri, 27 Feb 2015 19:11:48 +0100" while this Go code "fmt.Println(time.Now().Format(time.RFC822Z))" gives "27 Feb 15 19:12 +0100"

SpamAssassin is happy when sending with the Go format time.RFC1123Z

Is there a problem with the time pkg constant definitions ? RFC822 = "02 Jan 06 15:04 MST" RFC822Z = "02 Jan 06 15:04 -0700" // RFC822 with numeric zone

alexcesaro commented 9 years ago

In RFC 5322, the day name and seconds are optional so the time.RFC822 is not wrong. But nearly all emails in my inbox includes the day name and seconds. Also it looks like SpamAssassin does not recognize time.RFC822.

So thank you for pointing this issue! I will change the Gomail format to include day name and seconds.

alexcesaro commented 9 years ago

You were right I should not have used time.RFC822 which is an obsolete RFC (I am not sure why they included it in the time package). I will use time.RFC1123Z instead. Thanks!