Fixes issue #2087 - No mime_type on nil message (no message body) / email will not be processed.

This commit is contained in:
Martin Edenhofer 2018-07-04 13:37:56 +02:00
parent 5bbff10764
commit 3b107f0a31
3 changed files with 47 additions and 1 deletions

View file

@ -504,7 +504,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
def message_body_hash(mail) def message_body_hash(mail)
message = [mail.html_part, mail.text_part, mail].find { |m| m&.body.present? } message = [mail.html_part, mail.text_part, mail].find { |m| m&.body.present? }
if message.mime_type.nil? || message.mime_type.match?(%r{^text/(plain|html)$}) if message.present? && (message.mime_type.nil? || message.mime_type.match?(%r{^text/(plain|html)$}))
content_type = message.mime_type || 'text/plain' content_type = message.mime_type || 'text/plain'
body = body_text(message, strict_html: content_type.eql?('text/html')) body = body_text(message, strict_html: content_type.eql?('text/html'))
end end

View file

@ -0,0 +1,19 @@
Return-Path: <info@example.de>
X-Original-To: info@example.de
Delivered-To: m032b9f7@dd38536.example.com
Received: from dd38536.example.com (dd0801.example.com [1.1.1.1])
by dd38536.example.com (Postfix) with ESMTPSA id 343463D42403
for <info@example.de>; Wed, 4 Jul 2018 10:02:32 +0200 (CEST)
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-SenderIP: 1.1.1.1
User-Agent: ALL-INKL Webmail 2.11
Subject: Testmail - Alias in info@example.de Gruppe
From: "Bob Smith | deal" <info@example.de>
To: info@example.de
Message-Id: <20180704080232.343463D42403@dd38536.example.com>
Date: Wed, 4 Jul 2018 10:02:32 +0200 (CEST)
X-KasLoop: m032b9f7

View file

@ -2804,6 +2804,33 @@ Some Text',
}, },
}, },
}, },
{
data: File.read(Rails.root.join('test', 'data', 'mail', 'mail067.box')),
success: true,
result: {
0 => {
priority: '2 normal',
title: 'Testmail - Alias in info@example.de Gruppe',
},
1 => {
from: 'Bob Smith | deal <info@example.de>',
sender: 'Customer',
type: 'email',
subject: 'Testmail - Alias in info@example.de Gruppe',
body: 'no visible content',
},
},
verify: {
users: [
{
firstname: 'Bob',
lastname: 'Smith | deal',
fullname: 'Bob Smith | deal',
email: 'info@example.de',
},
],
},
},
] ]
assert_process(files) assert_process(files)
end end