Hi,
does anybody know if TMail supports nested multipart messages? I read
a changelog that indicates so
(http://dev.rubyonrails.org/svn/rails/trunk/actionmailer/CHANGELOG), but
I haven’t been able to get it working so far.
Maybe I am doing something wrong here?
I attached the sample mail. Here is the code to parse it:
require File.dirname(FILE) + ‘/…/test_helper’
class TMailTest < Test::Unit::TestCase
def test_multiparts
assert raw = File.read(“sample”)
assert mail = TMail::Mail.parse (raw)
puts “body=!#{body_as_plain_text
(mail)}!”
end
def body_as_plain_text(part)
body = ‘’
if part.multipart?
part.parts.each do |subpart|
if subpart.content_type == ‘text/plain’ and
subpart.content_disposition == ‘inline’
body << subpart.body
elsif subpart.content_type =~ /^multipart/
body << body_as_plain_text(subpart)
end
end
else
body = part.body
end
body
end
end
The output looks like this:
body=!Hi,
I have the following code:
@conversation_pages,
@conversations = paginate(:conversations,
:per_page => 20,
:joins => 'LEFT JOIN messages on
messages.conversation_id = conversations.id '+
‘LEFT JOIN
email_addresses on
email_addresses.id = messages.email_address_id’,
:conditions =>
['email_addresses.emai_______________________________________________
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
!
So the message is broken off at some point that looks arbitrary to me
(emai, 4th non-empty line from the bottom).
Any idea?
Cheers,
Mariano
Mariano,
Maybe you want to explain why you need nested multipart support? I
can’t answer your question but, if you explain what the use of such
functionality is, I may dig more into it.
Cheers,
daesan
On May 26, 2006, at 2:34 AM, Mariano K. wrote:
end
:conditions =>
Any idea?
Cheers,
Mariano
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
Dae San H.
[email protected]
Hi Dae,
thanks for showing some interest in it
A multipart message is a message that consists of more than one MIME
part. A nested mutlipart message consists of a mutlipart message that
contains other parts.
So for example the email you’ll find in the attachment contains two
parts that are alternatives for each other, one is text/plain and the
other one is the text/html representation of the same content. Both
are encoded ISO-8859-1 … And then there is a last part in the mail
that contains the RoR mailing list footer in text/plain, encoded as
US-ASCII.
So reading the changelog mentionend below I found the following:
1.0.0 (6 July, 2005)
…
- Better multipart support with implicit multipart/alternative and
sorting of subparts [John L.]
- Allow for nested parts in multipart mails #1570 [Flurin Egger]
When looking at this bug this seems more like an Action Mailer thing.
On the other hand though, TMail seems to be part of the Action Mailer
libraries.
I can also view the offending mail (see attachment) with ruby-forum
(Problem with joins and overlapping field names - Rails - Ruby-Forum)… And they use TMail too.
So I guess I am doing something wrong here, but I am not sure what.
Cheers,
Mariano
Glad to hear that you solved the problem.
Maybe you should report that to http://i.loveruby.net/en/projects/tmail/
cheers,
Daesan
On May 26, 2006, at 7:37 PM, Mariano K. wrote:
part. A nested mutlipart message consists of a mutlipart message that
1.0.0 (6 July, 2005)
I can also view the offending mail (see attachment) with ruby-forum
Maybe you want to explain why you need nested multipart support? I
I attached the sample mail. Here is the code to parse it:
end
end
body=!Hi,
email_addresses on
So the message is broken off at some point that looks arbitrary
http://lists.rubyonrails.org/mailman/listinfo/rails
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
Dae San H.
[email protected]
It works now.
So the short answert to my question is: Yes, TMail supports Nested
Mulipart Messages.
Why didn’t that work for me?
TMail uses message_text.unpack(‘M*’) to unpack quoted printables.
Unfortunately this chokes on CR/LFs. After replacing CR/LFs with LFs
it works now.
Cheers,
Mariano