From e68456bc388c28feda12902075a60175e55606de Mon Sep 17 00:00:00 2001 From: sejeong Date: Fri, 29 Apr 2016 15:18:40 +0900 Subject: [PATCH] find the text/plain part from multipart/related message --- lib/logstash/inputs/imap.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/logstash/inputs/imap.rb b/lib/logstash/inputs/imap.rb index 62dac2e..a90f16e 100644 --- a/lib/logstash/inputs/imap.rb +++ b/lib/logstash/inputs/imap.rb @@ -101,6 +101,12 @@ def parse_mail(mail) else # Multipart message; use the first text/plain part we find part = mail.parts.find { |p| p.content_type.match @content_type_re } || mail.parts.first + if part.content_type.start_with?('multipart/related') + part = part.parts.find { |p| p.content_type.match @content_type_re } || part.parts.first + end + if part.content_type.start_with?('multipart/alternative') + part = part.text_part + end message = part.decoded end