diff --git a/app/models/channel/email_parser.rb b/app/models/channel/email_parser.rb index 6ddc6d404..2390b7334 100644 --- a/app/models/channel/email_parser.rb +++ b/app/models/channel/email_parser.rb @@ -70,7 +70,7 @@ class Channel::EmailParser =end def parse(msg) - mail = Mail.new(msg.utf8_encode) + mail = Mail.new(msg.utf8_encode(from: charset_from_headers_of(msg))) message_attributes = [ { mail_instance: mail }, @@ -474,6 +474,13 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again private + def charset_from_headers_of(msg) + Mail.new(msg.b) + .header['Content-Type'] + .try(:parameters) + .try(:[], :charset) + end + def message_header_hash(mail) imported_fields = mail.header.fields.map do |f| value = begin diff --git a/test/data/mail/mail068.box b/test/data/mail/mail068.box new file mode 100644 index 000000000..375fa16cd --- /dev/null +++ b/test/data/mail/mail068.box @@ -0,0 +1,40 @@ +---- Original email message ---- +Return-Path: xxxx@mail.xxxxx.cz +X-Kerio-Anti-Spam: Build: [Engines: 2.15.8.1150, Stamp: 3], Multi: [Enabled, t: (0.000007,0.003682)], BW: [Enabled, t: (0.000008)], RTDA: [Enabled, t: (0.048902), Hit: No, Details: v2.7.13; Id: 15.1i6ap3s.1cjtibnrd.2nhht], total: 0(700) +X-Spam-Status: No, hits=0.0 required=5.0 +tests=KERIO_ANTI_SPAM: -0.000, BAYES_00: -1.665, HTML_MESSAGE: 0.001, +MIME_HEADER_CTYPE_ONLY: 0.717, MIME_HTML_ONLY: 0.723, TOTAL_SCORE: -0.224,autolearn=no +X-Spam-Level: +Received: from mail.xxxxx.cz ([xxx.168.xxx.xxx]) +by mail.xxxxxx.cz with ESMTP +for helpdesk@xxxxxx.cz; +Thu, 2 Aug 2018 16:58:16 +0200 +Received: by mail.xxxxx.cz (Postfix, from userid 500) +id 58E7387959; Thu, 2 Aug 2018 16:58:28 +0200 (CEST) +To: helpdek@xxxxx.cz +Subject: Contact from Server +X-PHP-Originating-Script: 500:kontact-info.inc.php +From: xxxxx@xxxxx.cz +Content-Type: text/html; charset="Windows-1250" +Message-Id: 20180802145828.58E7387959@mail.xxxxxx.cz +Date: Thu, 2 Aug 2018 16:58:28 +0200 (CEST) + +Contact form + +Odeslano dne: Čtvrtek 2. srpna 2018 16:58.28 + +Uzivatel: +Jmeno: Peter +E-mail: xxxxx@xxxxxx.cz +Problem: jine + + +