When dealing with mails of certain multipart structures, the gem can think that attachments are the text part of the email.
IF you consider an email of the following types:
Content-type: multipart/alternative;
Content-Type: text/plain
… here is the text
Content-Type: text/html
… here is the html
Works fine, but
another one:
Content-Type: multipart/mixed
Content-type: text/plain (or any other)
… attachment data here
Content-type: multipart/alternative;
Content-Type: text/plain
… here is the text
Content-Type: text/html
… here is the html
Ends up with a
undefined method `tr' for nil:NilClass
It's to do with this code that just assumes the first text it comes across is the right one.
Mail gem assigns a content type of text to anything it doesn't recognise, thus exascerbating the problem.
if payload.parts
[email protected]_all_object_containing("mimeType", "text/plain").first
if text_part
@values.text = urlsafe_decode64(text_part.body.data)
end
[email protected]_all_object_containing("mimeType", "text/html").first
if html_part
@values.html = urlsafe_decode64(html_part.body.data)
end
end
if payload.body.data
@values.body = urlsafe_decode64(@values.payload.body.data)
end
When dealing with mails of certain multipart structures, the gem can think that attachments are the text part of the email.
IF you consider an email of the following types:
Content-type: multipart/alternative;
Content-Type: text/plain
… here is the text
Content-Type: text/html
… here is the html
Works fine, but
another one:
Ends up with a
It's to do with this code that just assumes the first text it comes across is the right one.
Mail gem assigns a content type of text to anything it doesn't recognise, thus exascerbating the problem.