From 5930f27da7d776c2ddf23b53287a1967dbb85a4e Mon Sep 17 00:00:00 2001 From: miraclesu Date: Mon, 25 Jan 2016 22:55:40 +0800 Subject: [PATCH] Fix mail Chinese subject garbled bug --- utils/mail.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/mail.go b/utils/mail.go index 07043149..125fddd5 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -237,6 +237,9 @@ func (e *Email) Send() error { if len(e.From) == 0 { e.From = from.String() } + // use mail's RFC 5322 to encode any string + sub := mail.Address{e.Subject, ""} + e.Subject = strings.Trim(sub.String(), " <@>") raw, err := e.Bytes() if err != nil {