diff options
author | Asaad Mahmood <Unknowngi@live.com> | 2015-10-19 22:59:01 +0500 |
---|---|---|
committer | Asaad Mahmood <Unknowngi@live.com> | 2015-10-19 22:59:01 +0500 |
commit | 5135986a3b13c0a4474dbbca683d89ffbc1dead5 (patch) | |
tree | 42e511c01a0e707356091fd4d09911eb18b8ca20 /utils | |
parent | 2d42aefeafd2a0bea6419a6ef79c0c9b1fd313eb (diff) | |
parent | fd69910fab332642a7793e64064169e89eb0c3de (diff) | |
download | chat-5135986a3b13c0a4474dbbca683d89ffbc1dead5.tar.gz chat-5135986a3b13c0a4474dbbca683d89ffbc1dead5.tar.bz2 chat-5135986a3b13c0a4474dbbca683d89ffbc1dead5.zip |
Merge branch 'master' of https://github.com/mattermost/platform into ui-improvements
Diffstat (limited to 'utils')
-rw-r--r-- | utils/mail.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/utils/mail.go b/utils/mail.go index c91c15a6a..07a79eeb2 100644 --- a/utils/mail.go +++ b/utils/mail.go @@ -6,15 +6,22 @@ package utils import ( l4g "code.google.com/p/log4go" "crypto/tls" + "encoding/base64" "fmt" "github.com/mattermost/platform/model" - "html" "net" "net/mail" "net/smtp" "time" ) +func encodeRFC2047Word(s string) string { + // TODO: use `mime.BEncoding.Encode` instead when `go` >= 1.5 + // return mime.BEncoding.Encode("utf-8", s) + dst := base64.StdEncoding.EncodeToString([]byte(s)) + return "=?utf-8?b?" + dst + "?=" +} + func connectToSMTPServer(config *model.Config) (net.Conn, *model.AppError) { var conn net.Conn var err error @@ -102,9 +109,10 @@ func SendMailUsingConfig(to, subject, body string, config *model.Config) *model. headers := make(map[string]string) headers["From"] = fromMail.String() headers["To"] = toMail.String() - headers["Subject"] = html.UnescapeString(subject) + headers["Subject"] = encodeRFC2047Word(subject) headers["MIME-version"] = "1.0" - headers["Content-Type"] = "text/html" + headers["Content-Type"] = "text/html; charset=\"utf-8\"" + headers["Content-Transfer-Encoding"] = "8bit" headers["Date"] = time.Now().Format(time.RFC1123Z) message := "" |