Mariano Kamp
2006-May-25 17:34 UTC
[Rails] Does TMail support Nested Multipart Messages? (Repost)
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 Rails@lists.rubyonrails.org 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 -------------- next part -------------- A non-text attachment was scrubbed... Name: sample Type: application/octet-stream Size: 7048 bytes Desc: not available Url : http://wrath.rubyonrails.org/pipermail/rails/attachments/20060525/b8348a45/sample-0001.obj
Dae San Hwang
2006-May-25 17:49 UTC
[Rails] Does TMail support Nested Multipart Messages? (Repost)
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 Kamp wrote:> 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 > Rails@lists.rubyonrails.org > 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 > <sample> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsDae San Hwang daesan@gmail.com
Mariano Kamp
2006-May-25 18:09 UTC
[Rails] Does TMail support Nested Multipart Messages? (Repost)
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 andsorting of subparts [John Long]>> * 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 (http://www.ruby-forum.com/topic/66359)... And they use TMail too. So I guess I am doing something wrong here, but I am not sure what. Cheers, Mariano On 5/25/06, Dae San Hwang <daesan@gmail.com> wrote:> 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 Kamp wrote: > > > 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 > > Rails@lists.rubyonrails.org > > 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 > > <sample> > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > Dae San Hwang > daesan@gmail.com > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Mariano Kamp
2006-May-26 10:38 UTC
[Rails] [SOLVED] Does TMail support Nested Multipart Messages? (Repost)
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 On 5/25/06, Mariano Kamp <mariano.kamp@acm.org> wrote:> 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 Long] > >> * 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 > (http://www.ruby-forum.com/topic/66359)... And they use TMail too. > > So I guess I am doing something wrong here, but I am not sure what. > > Cheers, > Mariano > > On 5/25/06, Dae San Hwang <daesan@gmail.com> wrote: > > 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 Kamp wrote: > > > > > 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 > > > Rails@lists.rubyonrails.org > > > 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 > > > <sample> > > > _______________________________________________ > > > Rails mailing list > > > Rails@lists.rubyonrails.org > > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > Dae San Hwang > > daesan@gmail.com > > > > > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Dae San Hwang
2006-May-26 13:49 UTC
[Rails] [SOLVED] Does TMail support Nested Multipart Messages? (Repost)
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 Kamp wrote:> 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 > > On 5/25/06, Mariano Kamp <mariano.kamp@acm.org> wrote: >> 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 Long] >> >> * 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 >> (http://www.ruby-forum.com/topic/66359)... And they use TMail too. >> >> So I guess I am doing something wrong here, but I am not sure what. >> >> Cheers, >> Mariano >> >> On 5/25/06, Dae San Hwang <daesan@gmail.com> wrote: >> > 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 Kamp wrote: >> > >> > > 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 >> > > Rails@lists.rubyonrails.org >> > > 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 >> > > <sample> >> > > _______________________________________________ >> > > Rails mailing list >> > > Rails@lists.rubyonrails.org >> > > http://lists.rubyonrails.org/mailman/listinfo/rails >> > >> > Dae San Hwang >> > daesan@gmail.com >> > >> > >> > >> > _______________________________________________ >> > Rails mailing list >> > Rails@lists.rubyonrails.org >> > http://lists.rubyonrails.org/mailman/listinfo/rails >> > >> > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/railsDae San Hwang daesan@gmail.com