diff --git a/helpers/inbound/inbound.go b/helpers/inbound/inbound.go index 3c688fca..6f9a07c5 100644 --- a/helpers/inbound/inbound.go +++ b/helpers/inbound/inbound.go @@ -7,6 +7,7 @@ import ( "io/ioutil" "mime" "mime/multipart" + "mime/quotedprintable" "net/http" "strings" ) @@ -168,6 +169,26 @@ func (email *ParsedEmail) parseRawEmail(rawEmail string) error { return err } + // if Content-Type is not multipart just set the whole email + if raw == nil { + if len(sections) < 2 { + return nil + } + + wholeEmail := sections[1] + // decode if needed + if email.Headers["Content-Transfer-Encoding"] == "quoted-printable" { + decoded, err := ioutil.ReadAll(quotedprintable.NewReader(strings.NewReader(wholeEmail))) + if err != nil { + return err + } + wholeEmail = string(decoded) + } + + email.Body[email.Headers["Content-Type"]] = wholeEmail + return nil + } + for { emailPart, err := raw.NextPart() if err == io.EOF {