parent
66b14aa274
commit
f50016b008
3 changed files with 6720 additions and 4 deletions
|
@ -600,11 +600,27 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
|
||||||
end
|
end
|
||||||
|
|
||||||
def message_body_hash(mail)
|
def message_body_hash(mail)
|
||||||
message = [mail.html_part, mail.text_part, mail].find { |m| m&.body.present? }
|
if mail.html_part&.body.present?
|
||||||
|
content_type = mail.html_part.mime_type || 'text/plain'
|
||||||
|
body = body_text(mail.html_part, strict_html: true)
|
||||||
|
elsif mail.text_part.present?
|
||||||
|
content_type = 'text/plain'
|
||||||
|
|
||||||
if message.present? && (message.mime_type.nil? || message.mime_type.match?(%r{^text/(plain|html)$}))
|
body = mail
|
||||||
content_type = message.mime_type || 'text/plain'
|
.all_parts
|
||||||
body = body_text(message, strict_html: content_type.eql?('text/html'))
|
.reduce('') do |memo, part|
|
||||||
|
if part.mime_type == 'text/plain' && !part.attachment?
|
||||||
|
memo += body_text(part, strict_html: false)
|
||||||
|
elsif part.inline? && part.content_type&.start_with?('image')
|
||||||
|
content_type = 'text/html'
|
||||||
|
memo += "<img src=\'cid:#{part.cid}\'>"
|
||||||
|
end
|
||||||
|
|
||||||
|
memo
|
||||||
|
end
|
||||||
|
elsif mail&.body.present? && (mail.mime_type.nil? || mail.mime_type.match?(%r{^text/(plain|html)$}))
|
||||||
|
content_type = mail.mime_type || 'text/plain'
|
||||||
|
body = body_text(mail, strict_html: content_type.eql?('text/html'))
|
||||||
end
|
end
|
||||||
|
|
||||||
content_type = 'text/plain' if body.blank?
|
content_type = 'text/plain' if body.blank?
|
||||||
|
@ -685,6 +701,7 @@ process unprocessable_mails (tmp/unprocessable_mail/*.eml) again
|
||||||
def get_attachments(file, attachments, mail)
|
def get_attachments(file, attachments, mail)
|
||||||
return file.parts.map { |p| get_attachments(p, attachments, mail) } if file.parts.any?
|
return file.parts.map { |p| get_attachments(p, attachments, mail) } if file.parts.any?
|
||||||
return [] if [mail.text_part&.body&.encoded, mail.html_part&.body&.encoded].include?(file.body.encoded)
|
return [] if [mail.text_part&.body&.encoded, mail.html_part&.body&.encoded].include?(file.body.encoded)
|
||||||
|
return [] if file.content_type&.start_with?('text/plain') && !file.attachment?
|
||||||
|
|
||||||
# get file preferences
|
# get file preferences
|
||||||
headers_store = {}
|
headers_store = {}
|
||||||
|
|
6650
test/data/mail/mail102.box
Normal file
6650
test/data/mail/mail102.box
Normal file
File diff suppressed because it is too large
Load diff
49
test/data/mail/mail102.yml
Normal file
49
test/data/mail/mail102.yml
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue