From micho2 at gmx.de Wed Jul 16 06:52:48 2008 From: micho2 at gmx.de (micho edo) Date: Wed, 16 Jul 2008 12:52:48 +0200 Subject: [Tmail-talk] Problem with "encoded-word" (RFC2047)in subject Message-ID: <487DD300.6080608@gmx.de> Hi, I work with TMail with Ruby on Rails ActionMailer. Getting the subject of an incomming mail, I think TMail inserts spaces in the subjects where it should not. The subject is codes with "encoded-word" (RFC2047), TMail inserts after each "encoded-word" a blanc in the subject. Is there a workaround or am I doing something wrong. Tnx Micho PS: (normal E-Mail clients like thunderbird, outlookexpress or webmailer like googlemail show the subject correct) Example of the subject: Subject: =?ISO-8859-1?Q?Re:_Hause-Empfehlung.de_-xkcaihVSy?= =?ISO-8859-1?Q?UWXAsnp_-_Registrierungsbest=E4tigung?= From raasdnil at gmail.com Wed Jul 16 20:40:46 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Thu, 17 Jul 2008 10:40:46 +1000 Subject: [Tmail-talk] Problem with "encoded-word" (RFC2047)in subject In-Reply-To: <487DD300.6080608@gmx.de> References: <487DD300.6080608@gmx.de> Message-ID: <57a815bf0807161740s26165d2aq462ddaf2ee288eb5@mail.gmail.com> On Wed, Jul 16, 2008 at 8:52 PM, micho edo wrote: > I work with TMail with Ruby on Rails ActionMailer. > Getting the subject of an incomming mail, I think TMail inserts spaces in > the subjects where it should not. Hmm... > The subject is codes with "encoded-word" (RFC2047), TMail inserts after each > "encoded-word" a blanc in the subject. > Is there a workaround or am I doing something wrong. Not that I am aware of. Could you write a test case on what behaviour you should see and show a failing test? Then I can go about fixing it. Mikel -- http://lindsaar.net/ Rails, RSpec and Life blog.... From mark at mackframework.com Wed Jul 23 21:07:09 2008 From: mark at mackframework.com (Mark Bates) Date: Wed, 23 Jul 2008 21:07:09 -0400 Subject: [Tmail-talk] Adding attachments Message-ID: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> Hi, I'm trying to add a TMail adapter to the Mack Framework, but I'm having problems with attachments. There's not a whole lot of documentation on the subject, so I thought I would turn to the gurus. I want to be able to add a plain text version, an html version, and an attachment in the email. When I do this I see all 3 displayed in a row in my email client. Here's my simple test script: ### --- require 'rubygems' require 'net/smtp' require 'tmail' require 'base64' def deliver(mail) Net::SMTP.start("localhost", 25) do |smtp| smtp.sendmail(mail.encoded, mail.reply_to, mail.destinations) end end # setup general mail settings: mail = TMail::Mail.new mail.mime_version = "1.0" mail.to = "mark at mackframework.com" mail.from = "mark at mackframework.com" mail.reply_to = mail.from mail.subject = "hello world" # Add the text/plain portion text = TMail::Mail.new text.mime_version = "1.0" text.content_type = "text/plain" text.body = "this is my plain text email" mail.parts << text # Add the text/html portion html = TMail::Mail.new text.mime_version = "1.0" html.content_type = "text/html" html.body = "this is my HTML email" mail.parts << html # Add an attachment content = File.read("/Users/markbates/mark-simpson.png") attachment = TMail::Mail.new attachment.body = Base64.encode64(content) attachment.transfer_encoding = "Base64" attachment.content_type = "application/octet-stream" attachment['Content-Disposition'] = "attachment; filename=foo.png" mail.parts << attachment mail.content_type = "multipart/mixed" deliver(mail) ### --- Any help would be great! Thanks. ------------------------------------------------------------------------------------------------- Mark Bates mark at mackframework.com http://www.mackframework.com http://api.mackframework.com/ http://github.com/markbates/mack From raasdnil at gmail.com Wed Jul 23 21:55:02 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Thu, 24 Jul 2008 11:55:02 +1000 Subject: [Tmail-talk] Adding attachments In-Reply-To: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> Message-ID: <57a815bf0807231855p33726936re8c25bd82461a7e4@mail.gmail.com> On Thu, Jul 24, 2008 at 11:07 AM, Mark Bates wrote: > Hi, I'm trying to add a TMail adapter to the Mack Framework, but I'm having > problems with attachments. There's not a whole lot of documentation on the > subject, so I thought I would turn to the gurus. What problem are you having? Mikel -- http://lindsaar.net/ Rails, RSpec and Life blog.... From mark at mackframework.com Wed Jul 23 22:15:27 2008 From: mark at mackframework.com (Mark Bates) Date: Wed, 23 Jul 2008 22:15:27 -0400 Subject: [Tmail-talk] Adding attachments In-Reply-To: <57a815bf0807231855p33726936re8c25bd82461a7e4@mail.gmail.com> References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> <57a815bf0807231855p33726936re8c25bd82461a7e4@mail.gmail.com> Message-ID: <353D5488-2054-4CE9-A029-3FE77D16FFCC@mackframework.com> Thanks for the quick response Mikel. There was a lot more to my original email, that outlines the problems I'm having. I've pasted it below. Thanks for the help. I want to be able to add a plain text version, an html version, and an attachment in the email. When I do this I see all 3 displayed in a row in my email client. Here's my simple test script: ### --- require 'rubygems' require 'net/smtp' require 'tmail' require 'base64' def deliver(mail) Net::SMTP.start("localhost", 25) do |smtp| smtp.sendmail(mail.encoded, mail.reply_to, mail.destinations) end end # setup general mail settings: mail = TMail::Mail.new mail.mime_version = "1.0" mail.to = "mark at mackframework.com" mail.from = "mark at mackframework.com" mail.reply_to = mail.from mail.subject = "hello world" # Add the text/plain portion text = TMail::Mail.new text.mime_version = "1.0" text.content_type = "text/plain" text.body = "this is my plain text email" mail.parts << text # Add the text/html portion html = TMail::Mail.new text.mime_version = "1.0" html.content_type = "text/html" html.body = "this is my HTML email" mail.parts << html # Add an attachment content = File.read("/Users/markbates/mark-simpson.png") attachment = TMail::Mail.new attachment.body = Base64.encode64(content) attachment.transfer_encoding = "Base64" attachment.content_type = "application/octet-stream" attachment['Content-Disposition'] = "attachment; filename=foo.png" mail.parts << attachment mail.content_type = "multipart/mixed" deliver(mail) ### --- ------------------------------------------------------------------------------------------------- Mark Bates mark at mackframework.com http://www.mackframework.com http://api.mackframework.com/ http://github.com/markbates/mack On Jul 23, 2008, at 9:55 PM, Mikel Lindsaar wrote: > On Thu, Jul 24, 2008 at 11:07 AM, Mark Bates > wrote: >> Hi, I'm trying to add a TMail adapter to the Mack Framework, but >> I'm having >> problems with attachments. There's not a whole lot of documentation >> on the >> subject, so I thought I would turn to the gurus. > > What problem are you having? > > Mikel > > -- > http://lindsaar.net/ > Rails, RSpec and Life blog.... > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk -------------- next part -------------- An HTML attachment was scrubbed... URL: From raasdnil at gmail.com Wed Jul 23 23:17:43 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Thu, 24 Jul 2008 13:17:43 +1000 Subject: [Tmail-talk] Adding attachments In-Reply-To: <353D5488-2054-4CE9-A029-3FE77D16FFCC@mackframework.com> References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> <57a815bf0807231855p33726936re8c25bd82461a7e4@mail.gmail.com> <353D5488-2054-4CE9-A029-3FE77D16FFCC@mackframework.com> Message-ID: <57a815bf0807232017q4fab6a05idb42dc67ff37df8c@mail.gmail.com> On Thu, Jul 24, 2008 at 12:15 PM, Mark Bates wrote: > Thanks for the quick response Mikel. There was a lot more to my original > email, that outlines the problems I'm having. I've pasted it below. Thanks > for the help. Dear Mark, No, I have now read your test script twice, and I still don't have the answer to my question to help you answer your question. You say something vague about being able to see all the parts of the email in the email client. Isn't this what you are after? What is your expected behaviour? Does it happen when you send HTML only? Does it only happen when you add an attachment? Mikel -- http://lindsaar.net/ Rails, RSpec and Life blog.... From mark at mackframework.com Wed Jul 23 23:53:14 2008 From: mark at mackframework.com (Mark Bates) Date: Wed, 23 Jul 2008 23:53:14 -0400 Subject: [Tmail-talk] Adding attachments In-Reply-To: <57a815bf0807232017q4fab6a05idb42dc67ff37df8c@mail.gmail.com> References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> <57a815bf0807231855p33726936re8c25bd82461a7e4@mail.gmail.com> <353D5488-2054-4CE9-A029-3FE77D16FFCC@mackframework.com> <57a815bf0807232017q4fab6a05idb42dc67ff37df8c@mail.gmail.com> Message-ID: Hi Mikel, let me try an clarify. Let's take a simple case, to start with, when you send an email that has a text/plain and a text/html part, email clients should read that and show you the part that is relevant to you. Meaning that if you say I only want to view my emails in plain text, you'll see the text/plain part and not the text/html part. I believe I have that working with TMail using the content type multipart/alternative. Now, when I add an attachment to the email, I want that attachment to show up in my email client as just that, an attachment. What is happening, however, is the attachment, as well as the text/ plain, and the text/html parts are all showing up in my email client as one big 'body'. My email client does show the attachment as an attachment, which is great. But the problem I have is that I'm now seeing all three parts showing in the 'body' of my email, like this: This is my plain text email.This is my HTML email.. Does that help clarify what the problem is? What I want to see is the text/plain version, with an attachment, if I tell my email client that's what I want, or the text/html version with an attachment, if that's what I specify. If you still don't quite understand this, and I know I'm not making the problem terribly clear, let me just ask you, how would you create a multipart email with an attachment using TMail? This, incidentally, would make a great section on the Getting Start pages, as it's something a lot of people do. I've included my headers below, in case that helps you. Thanks. Received: from biglaptop.local ([96.252.48.194]) by mail.helium.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 23 Jul 2008 23:48:21 -0400 Received: from localhost.localdomain (localhost [127.0.0.1]) by biglaptop.local (Postfix) with ESMTP id EAC381E2952E for ; Wed, 23 Jul 2008 23:48:20 -0400 (EDT) From: mark at mackframework.com Reply-To: mark at mackframework.com To: mbates at helium.com Subject: hello world Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=mimepart_4887fb84e1724_42641a37e1f Message-Id: <20080724034820.EAC381E2952E at biglaptop.local> Date: Wed, 23 Jul 2008 23:48:20 -0400 (EDT) Return-Path: mark at mackframework.com X-OriginalArrivalTime: 24 Jul 2008 03:48:21.0397 (UTC) FILETIME=[1DD0C450:01C8ED40] X-TM-AS-Product-Ver: SMEX-7.5.0.1243-5.5.1027-16050.003 X-TM-AS-Result: No--3.942000-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No --mimepart_4887fb84e1724_42641a37e1f Mime-Version: 1.0 Content-Type: text/plain this is my plain text email --mimepart_4887fb84e1724_42641a37e1f Content-Type: text/html this is my HTML email --mimepart_4887fb84e1724_42641a37e1f Content-Type: application/octet-stream Content-Transfer-Encoding: Base64 Content-Disposition: attachment; filename=foo.png ------------------------------------------------------------------------------------------------- Mark Bates mark at mackframework.com http://www.mackframework.com http://api.mackframework.com/ http://github.com/markbates/mack On Jul 23, 2008, at 11:17 PM, Mikel Lindsaar wrote: > On Thu, Jul 24, 2008 at 12:15 PM, Mark Bates > wrote: >> Thanks for the quick response Mikel. There was a lot more to my >> original >> email, that outlines the problems I'm having. I've pasted it below. >> Thanks >> for the help. > > Dear Mark, > > No, I have now read your test script twice, and I still don't have the > answer to my question to help you answer your question. > > You say something vague about being able to see all the parts of the > email in the email client. Isn't this what you are after? What is > your expected behaviour? Does it happen when you send HTML only? > Does it only happen when you add an attachment? > > Mikel > > -- > http://lindsaar.net/ > Rails, RSpec and Life blog.... > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk From raasdnil at gmail.com Thu Jul 24 00:11:09 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Thu, 24 Jul 2008 14:11:09 +1000 Subject: [Tmail-talk] Adding attachments In-Reply-To: References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> <57a815bf0807231855p33726936re8c25bd82461a7e4@mail.gmail.com> <353D5488-2054-4CE9-A029-3FE77D16FFCC@mackframework.com> <57a815bf0807232017q4fab6a05idb42dc67ff37df8c@mail.gmail.com> Message-ID: <57a815bf0807232111m6f0acd35uc689eb09f754035b@mail.gmail.com> On Thu, Jul 24, 2008 at 1:53 PM, Mark Bates wrote: > This is my plain text email.This is my HTML > email.. Oh, I see what you mean now. > If you still don't quite understand this, and I know I'm not making the > problem terribly clear, let me just ask you, how would you create a > multipart email with an attachment using TMail? This, incidentally, would > make a great section on the Getting Start pages, as it's something a lot of > people do. Good idea. What email client are you using? Mikel -- http://lindsaar.net/ Rails, RSpec and Life blog.... From raasdnil at gmail.com Thu Jul 24 00:29:56 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Thu, 24 Jul 2008 14:29:56 +1000 Subject: [Tmail-talk] Adding attachments In-Reply-To: <57a815bf0807232111m6f0acd35uc689eb09f754035b@mail.gmail.com> References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> <57a815bf0807231855p33726936re8c25bd82461a7e4@mail.gmail.com> <353D5488-2054-4CE9-A029-3FE77D16FFCC@mackframework.com> <57a815bf0807232017q4fab6a05idb42dc67ff37df8c@mail.gmail.com> <57a815bf0807232111m6f0acd35uc689eb09f754035b@mail.gmail.com> Message-ID: <57a815bf0807232129uaa139bfjdfb131dd1b9b035d@mail.gmail.com> Dear Mark, Try setting: mail.set_content_type 'multipart', 'mixed', {'boundary' => TMail.new_boundary} At the top in the first 'mail' block. You have to set the multipart and mixed separately. You can set the boundary to whatever you want, but the new_boundary method is handy. See below for the whole script. >> multipart email with an attachment using TMail? This, incidentally, would >> make a great section on the Getting Start pages, as it's something a lot of >> people do. Feel like writing one up? :) I'll put it up if you do :) Mikel ---------- require 'rubygems' require 'tmail' require 'base64' # setup general mail settings: mail = TMail::Mail.new mail.mime_version = "1.0" mail.to = "mark at mackframework.com" mail.from = "mark at mackframework.com" mail.reply_to = mail.from mail.subject = "hello world" mail.set_content_type 'multipart', 'mixed', {'boundary' => TMail.new_boundary} # Add the text/plain portion text = TMail::Mail.new text.mime_version = "1.0" text.content_type = "text/plain" text.body = "this is my plain text email" mail.parts << text # Add the text/html portion html = TMail::Mail.new text.mime_version = "1.0" html.content_type = "text/html" html.body = "this is my HTML email" mail.parts << html # Add an attachment content = File.read("/Users/mikel/Pictures/MyPicture.jpg") attachment = TMail::Mail.new attachment.body = Base64.encode64(content) attachment.transfer_encoding = "Base64" attachment.content_type = "application/octet-stream" attachment['Content-Disposition'] = "attachment; filename=MyPicture.jpg" mail.parts << attachment File.open('testemail.eml', 'w') do |f| f.puts mail.encoded end From mark at mackframework.com Thu Jul 24 07:45:44 2008 From: mark at mackframework.com (Mark Bates) Date: Thu, 24 Jul 2008 07:45:44 -0400 Subject: [Tmail-talk] Adding attachments In-Reply-To: <57a815bf0807232129uaa139bfjdfb131dd1b9b035d@mail.gmail.com> References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> <57a815bf0807231855p33726936re8c25bd82461a7e4@mail.gmail.com> <353D5488-2054-4CE9-A029-3FE77D16FFCC@mackframework.com> <57a815bf0807232017q4fab6a05idb42dc67ff37df8c@mail.gmail.com> <57a815bf0807232111m6f0acd35uc689eb09f754035b@mail.gmail.com> <57a815bf0807232129uaa139bfjdfb131dd1b9b035d@mail.gmail.com> Message-ID: Setting: > mail.set_content_type 'multipart', 'mixed', {'boundary' => > TMail.new_boundary} Gives me the same results. I'm using Apple Mail (Leopard), but I also see the same thing happening in GMail and Yahoo. The clients I've tested are all handling the attachments correctly, it's the text & html parts that I don't think it's handling correctly. They're all showing both, and not just one of them. Once I get this all worked out, I'll be more than happy to write a tutorial on doing multipart messages and attachments. I'm always willing to give back. :) ------------------------------------------------------------------------------------------------- Mark Bates mark at mackframework.com http://www.mackframework.com http://api.mackframework.com/ http://github.com/markbates/mack On Jul 24, 2008, at 12:29 AM, Mikel Lindsaar wrote: > Dear Mark, > > Try setting: > > mail.set_content_type 'multipart', 'mixed', {'boundary' => > TMail.new_boundary} > > At the top in the first 'mail' block. You have to set the multipart > and mixed separately. You can set the boundary to whatever you want, > but the new_boundary method is handy. > > See below for the whole script. > >>> multipart email with an attachment using TMail? This, >>> incidentally, would >>> make a great section on the Getting Start pages, as it's something >>> a lot of >>> people do. > > Feel like writing one up? :) I'll put it up if you do :) > > Mikel > > ---------- > > require 'rubygems' > require 'tmail' > require 'base64' > > # setup general mail settings: > mail = TMail::Mail.new > mail.mime_version = "1.0" > mail.to = "mark at mackframework.com" > mail.from = "mark at mackframework.com" > mail.reply_to = mail.from > mail.subject = "hello world" > mail.set_content_type 'multipart', 'mixed', {'boundary' => > TMail.new_boundary} > > # Add the text/plain portion > text = TMail::Mail.new > text.mime_version = "1.0" > text.content_type = "text/plain" > text.body = "this is my plain text email" > mail.parts << text > > # Add the text/html portion > html = TMail::Mail.new > text.mime_version = "1.0" > html.content_type = "text/html" > html.body = "this is my HTML email" > mail.parts << html > > # Add an attachment > content = File.read("/Users/mikel/Pictures/MyPicture.jpg") > attachment = TMail::Mail.new > attachment.body = Base64.encode64(content) > attachment.transfer_encoding = "Base64" > attachment.content_type = "application/octet-stream" > attachment['Content-Disposition'] = "attachment; > filename=MyPicture.jpg" > mail.parts << attachment > > File.open('testemail.eml', 'w') do |f| > f.puts mail.encoded > end > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk From aquasync at gmail.com Thu Jul 24 11:25:57 2008 From: aquasync at gmail.com (charles) Date: Thu, 24 Jul 2008 11:25:57 -0400 Subject: [Tmail-talk] Adding attachments In-Reply-To: References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> <57a815bf0807231855p33726936re8c25bd82461a7e4@mail.gmail.com> <353D5488-2054-4CE9-A029-3FE77D16FFCC@mackframework.com> <57a815bf0807232017q4fab6a05idb42dc67ff37df8c@mail.gmail.com> <57a815bf0807232111m6f0acd35uc689eb09f754035b@mail.gmail.com> <57a815bf0807232129uaa139bfjdfb131dd1b9b035d@mail.gmail.com> Message-ID: <89bd8880807240825j20a9ab80n88aacca5060877d6@mail.gmail.com> You need to bundle the 2 alternate body types into a parent part. Ie, the email should look something like this: irb(main):006:0> puts msg.to_mime.to_tree - # |- # | |- # | \- # \- # I've a patch somewhere that adds a similar "tree view" output to tmail objects which is helpful for debugging this stuff. On Thu, Jul 24, 2008 at 7:45 AM, Mark Bates wrote: > Setting: > > mail.set_content_type 'multipart', 'mixed', {'boundary' => >> TMail.new_boundary} >> > > Gives me the same results. > > I'm using Apple Mail (Leopard), but I also see the same thing happening in > GMail and Yahoo. The clients I've tested are all handling the attachments > correctly, it's the text & html parts that I don't think it's handling > correctly. They're all showing both, and not just one of them. > > Once I get this all worked out, I'll be more than happy to write a tutorial > on doing multipart messages and attachments. I'm always willing to give > back. :) > > > ------------------------------------------------------------------------------------------------- > Mark Bates > mark at mackframework.com > http://www.mackframework.com > http://api.mackframework.com/ > http://github.com/markbates/mack > > > > On Jul 24, 2008, at 12:29 AM, Mikel Lindsaar wrote: > > Dear Mark, >> >> Try setting: >> >> mail.set_content_type 'multipart', 'mixed', {'boundary' => >> TMail.new_boundary} >> >> At the top in the first 'mail' block. You have to set the multipart >> and mixed separately. You can set the boundary to whatever you want, >> but the new_boundary method is handy. >> >> See below for the whole script. >> >> multipart email with an attachment using TMail? This, incidentally, would >>>> make a great section on the Getting Start pages, as it's something a lot >>>> of >>>> people do. >>>> >>> >> Feel like writing one up? :) I'll put it up if you do :) >> >> Mikel >> >> ---------- >> >> require 'rubygems' >> require 'tmail' >> require 'base64' >> >> # setup general mail settings: >> mail = TMail::Mail.new >> mail.mime_version = "1.0" >> mail.to = "mark at mackframework.com" >> mail.from = "mark at mackframework.com" >> mail.reply_to = mail.from >> mail.subject = "hello world" >> mail.set_content_type 'multipart', 'mixed', {'boundary' => >> TMail.new_boundary} >> >> # Add the text/plain portion >> text = TMail::Mail.new >> text.mime_version = "1.0" >> text.content_type = "text/plain" >> text.body = "this is my plain text email" >> mail.parts << text >> >> # Add the text/html portion >> html = TMail::Mail.new >> text.mime_version = "1.0" >> html.content_type = "text/html" >> html.body = "this is my HTML email" >> mail.parts << html >> >> # Add an attachment >> content = File.read("/Users/mikel/Pictures/MyPicture.jpg") >> attachment = TMail::Mail.new >> attachment.body = Base64.encode64(content) >> attachment.transfer_encoding = "Base64" >> attachment.content_type = "application/octet-stream" >> attachment['Content-Disposition'] = "attachment; filename=MyPicture.jpg" >> mail.parts << attachment >> >> File.open('testemail.eml', 'w') do |f| >> f.puts mail.encoded >> end >> _______________________________________________ >> Tmail-talk mailing list >> Tmail-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/tmail-talk >> > > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mark at mackframework.com Thu Jul 24 12:06:38 2008 From: mark at mackframework.com (Mark Bates) Date: Thu, 24 Jul 2008 12:06:38 -0400 Subject: [Tmail-talk] Adding attachments In-Reply-To: <89bd8880807240825j20a9ab80n88aacca5060877d6@mail.gmail.com> References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> <57a815bf0807231855p33726936re8c25bd82461a7e4@mail.gmail.com> <353D5488-2054-4CE9-A029-3FE77D16FFCC@mackframework.com> <57a815bf0807232017q4fab6a05idb42dc67ff37df8c@mail.gmail.com> <57a815bf0807232111m6f0acd35uc689eb09f754035b@mail.gmail.com> <57a815bf0807232129uaa139bfjdfb131dd1b9b035d@mail.gmail.com> <89bd8880807240825j20a9ab80n88aacca5060877d6@mail.gmail.com> Message-ID: <279C7F2F-652A-4221-9AC6-E19D361350F9@mackframework.com> YES!! That's it! Thanks so much! You just made my day. :) ------------------------------------------------------------------------------------------------- Mark Bates mark at mackframework.com http://www.mackframework.com http://api.mackframework.com/ http://github.com/markbates/mack On Jul 24, 2008, at 11:25 AM, charles wrote: > You need to bundle the 2 alternate body types into a parent part. > Ie, the email should look something like this: > > irb(main):006:0> puts msg.to_mime.to_tree > - # > |- # > | |- # > | \- # > \- # > > I've a patch somewhere that adds a similar "tree view" output to > tmail objects which is helpful for debugging this stuff. > > On Thu, Jul 24, 2008 at 7:45 AM, Mark Bates > wrote: > Setting: > > mail.set_content_type 'multipart', 'mixed', {'boundary' => > TMail.new_boundary} > > Gives me the same results. > > I'm using Apple Mail (Leopard), but I also see the same thing > happening in GMail and Yahoo. The clients I've tested are all > handling the attachments correctly, it's the text & html parts that > I don't think it's handling correctly. They're all showing both, and > not just one of them. > > Once I get this all worked out, I'll be more than happy to write a > tutorial on doing multipart messages and attachments. I'm always > willing to give back. :) > > ------------------------------------------------------------------------------------------------- > > Mark Bates > mark at mackframework.com > http://www.mackframework.com > http://api.mackframework.com/ > http://github.com/markbates/mack > > > > On Jul 24, 2008, at 12:29 AM, Mikel Lindsaar wrote: > > Dear Mark, > > Try setting: > > mail.set_content_type 'multipart', 'mixed', {'boundary' => > TMail.new_boundary} > > At the top in the first 'mail' block. You have to set the multipart > and mixed separately. You can set the boundary to whatever you want, > but the new_boundary method is handy. > > See below for the whole script. > > multipart email with an attachment using TMail? This, incidentally, > would > make a great section on the Getting Start pages, as it's something a > lot of > people do. > > Feel like writing one up? :) I'll put it up if you do :) > > Mikel > > ---------- > > require 'rubygems' > require 'tmail' > require 'base64' > > # setup general mail settings: > mail = TMail::Mail.new > mail.mime_version = "1.0" > mail.to = "mark at mackframework.com" > mail.from = "mark at mackframework.com" > mail.reply_to = mail.from > mail.subject = "hello world" > mail.set_content_type 'multipart', 'mixed', {'boundary' => > TMail.new_boundary} > > # Add the text/plain portion > text = TMail::Mail.new > text.mime_version = "1.0" > text.content_type = "text/plain" > text.body = "this is my plain text email" > mail.parts << text > > # Add the text/html portion > html = TMail::Mail.new > text.mime_version = "1.0" > html.content_type = "text/html" > html.body = "this is my HTML email" > mail.parts << html > > # Add an attachment > content = File.read("/Users/mikel/Pictures/MyPicture.jpg") > attachment = TMail::Mail.new > attachment.body = Base64.encode64(content) > attachment.transfer_encoding = "Base64" > attachment.content_type = "application/octet-stream" > attachment['Content-Disposition'] = "attachment; > filename=MyPicture.jpg" > mail.parts << attachment > > File.open('testemail.eml', 'w') do |f| > f.puts mail.encoded > end > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk > > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk > > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at kikobu.com Thu Jul 24 15:47:39 2008 From: lists at kikobu.com (Morten) Date: Thu, 24 Jul 2008 21:47:39 +0200 Subject: [Tmail-talk] Is this correct? Message-ID: <462BA556-7D9D-498E-861A-73F5DB0D4A5A@kikobu.com> >> TMail::Address.parse('no_valid_email') => # I know that you have a massive test repository, but I'm just surprised that an email address doesn't have to contain an @ Br, Morten From aquasync at gmail.com Thu Jul 24 17:02:21 2008 From: aquasync at gmail.com (charles) Date: Thu, 24 Jul 2008 17:02:21 -0400 Subject: [Tmail-talk] Adding attachments In-Reply-To: <279C7F2F-652A-4221-9AC6-E19D361350F9@mackframework.com> References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> <57a815bf0807231855p33726936re8c25bd82461a7e4@mail.gmail.com> <353D5488-2054-4CE9-A029-3FE77D16FFCC@mackframework.com> <57a815bf0807232017q4fab6a05idb42dc67ff37df8c@mail.gmail.com> <57a815bf0807232111m6f0acd35uc689eb09f754035b@mail.gmail.com> <57a815bf0807232129uaa139bfjdfb131dd1b9b035d@mail.gmail.com> <89bd8880807240825j20a9ab80n88aacca5060877d6@mail.gmail.com> <279C7F2F-652A-4221-9AC6-E19D361350F9@mackframework.com> Message-ID: <89bd8880807241402r1c364ecxbdda868b14cd53ad@mail.gmail.com> No problems - happy to help! On Thu, Jul 24, 2008 at 12:06 PM, Mark Bates wrote: > YES!! That's it! Thanks so much! You just made my day. :) > > > ------------------------------------------------------------------------------------------------- > Mark Bates > mark at mackframework.com > http://www.mackframework.com > http://api.mackframework.com/ > http://github.com/markbates/mack > > > > On Jul 24, 2008, at 11:25 AM, charles wrote: > > You need to bundle the 2 alternate body types into a parent part. Ie, the > email should look something like this: > > irb(main):006:0> puts msg.to_mime.to_tree > - # > |- # > | |- # > | \- # > \- # > > I've a patch somewhere that adds a similar "tree view" output to tmail > objects which is helpful for debugging this stuff. > > On Thu, Jul 24, 2008 at 7:45 AM, Mark Bates > wrote: > >> Setting: >> >> mail.set_content_type 'multipart', 'mixed', {'boundary' => >>> TMail.new_boundary} >>> >> >> Gives me the same results. >> >> I'm using Apple Mail (Leopard), but I also see the same thing happening in >> GMail and Yahoo. The clients I've tested are all handling the attachments >> correctly, it's the text & html parts that I don't think it's handling >> correctly. They're all showing both, and not just one of them. >> >> Once I get this all worked out, I'll be more than happy to write a >> tutorial on doing multipart messages and attachments. I'm always willing to >> give back. :) >> >> >> ------------------------------------------------------------------------------------------------- >> Mark Bates >> mark at mackframework.com >> http://www.mackframework.com >> http://api.mackframework.com/ >> http://github.com/markbates/mack >> >> >> >> On Jul 24, 2008, at 12:29 AM, Mikel Lindsaar wrote: >> >> Dear Mark, >>> >>> Try setting: >>> >>> mail.set_content_type 'multipart', 'mixed', {'boundary' => >>> TMail.new_boundary} >>> >>> At the top in the first 'mail' block. You have to set the multipart >>> and mixed separately. You can set the boundary to whatever you want, >>> but the new_boundary method is handy. >>> >>> See below for the whole script. >>> >>> multipart email with an attachment using TMail? This, incidentally, >>>>> would >>>>> make a great section on the Getting Start pages, as it's something a >>>>> lot of >>>>> people do. >>>>> >>>> >>> Feel like writing one up? :) I'll put it up if you do :) >>> >>> Mikel >>> >>> ---------- >>> >>> require 'rubygems' >>> require 'tmail' >>> require 'base64' >>> >>> # setup general mail settings: >>> mail = TMail::Mail.new >>> mail.mime_version = "1.0" >>> mail.to = "mark at mackframework.com" >>> mail.from = "mark at mackframework.com" >>> mail.reply_to = mail.from >>> mail.subject = "hello world" >>> mail.set_content_type 'multipart', 'mixed', {'boundary' => >>> TMail.new_boundary} >>> >>> # Add the text/plain portion >>> text = TMail::Mail.new >>> text.mime_version = "1.0" >>> text.content_type = "text/plain" >>> text.body = "this is my plain text email" >>> mail.parts << text >>> >>> # Add the text/html portion >>> html = TMail::Mail.new >>> text.mime_version = "1.0" >>> html.content_type = "text/html" >>> html.body = "this is my HTML email" >>> mail.parts << html >>> >>> # Add an attachment >>> content = File.read("/Users/mikel/Pictures/MyPicture.jpg") >>> attachment = TMail::Mail.new >>> attachment.body = Base64.encode64(content) >>> attachment.transfer_encoding = "Base64" >>> attachment.content_type = "application/octet-stream" >>> attachment['Content-Disposition'] = "attachment; filename=MyPicture.jpg" >>> mail.parts << attachment >>> >>> File.open('testemail.eml', 'w') do |f| >>> f.puts mail.encoded >>> end >>> _______________________________________________ >>> Tmail-talk mailing list >>> Tmail-talk at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/tmail-talk >>> >> >> _______________________________________________ >> Tmail-talk mailing list >> Tmail-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/tmail-talk >> > > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk > > > > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From raasdnil at gmail.com Thu Jul 24 20:19:37 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Fri, 25 Jul 2008 10:19:37 +1000 Subject: [Tmail-talk] Adding attachments In-Reply-To: <89bd8880807240825j20a9ab80n88aacca5060877d6@mail.gmail.com> References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> <57a815bf0807231855p33726936re8c25bd82461a7e4@mail.gmail.com> <353D5488-2054-4CE9-A029-3FE77D16FFCC@mackframework.com> <57a815bf0807232017q4fab6a05idb42dc67ff37df8c@mail.gmail.com> <57a815bf0807232111m6f0acd35uc689eb09f754035b@mail.gmail.com> <57a815bf0807232129uaa139bfjdfb131dd1b9b035d@mail.gmail.com> <89bd8880807240825j20a9ab80n88aacca5060877d6@mail.gmail.com> Message-ID: <57a815bf0807241719v5d1ff782mad86ac6c14173fd2@mail.gmail.com> On Fri, Jul 25, 2008 at 1:25 AM, charles wrote: > irb(main):006:0> puts msg.to_mime.to_tree > - # > |- # > | |- # > | \- # > \- # > > I've a patch somewhere that adds a similar "tree view" output to tmail > objects which is helpful for debugging this stuff. Gimmie, I'll put it into the tree. That looks useful. -- http://lindsaar.net/ Rails, RSpec and Life blog.... From raasdnil at gmail.com Thu Jul 24 20:20:33 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Fri, 25 Jul 2008 10:20:33 +1000 Subject: [Tmail-talk] Is this correct? In-Reply-To: <462BA556-7D9D-498E-861A-73F5DB0D4A5A@kikobu.com> References: <462BA556-7D9D-498E-861A-73F5DB0D4A5A@kikobu.com> Message-ID: <57a815bf0807241720t2b6b561pee3e11cad77975cc@mail.gmail.com> On Fri, Jul 25, 2008 at 5:47 AM, Morten wrote: >>> TMail::Address.parse('no_valid_email') > => # > > I know that you have a massive test repository, but I'm just surprised that > an email address doesn't have to contain an @ Yes, you can send email to another person on your system without an email address. The SMTP gateway will attempt to deliver it locally. Mikel -- http://lindsaar.net/ Rails, RSpec and Life blog.... From aquasync at gmail.com Fri Jul 25 11:56:53 2008 From: aquasync at gmail.com (charles) Date: Fri, 25 Jul 2008 11:56:53 -0400 Subject: [Tmail-talk] Adding attachments In-Reply-To: <57a815bf0807241719v5d1ff782mad86ac6c14173fd2@mail.gmail.com> References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> <57a815bf0807231855p33726936re8c25bd82461a7e4@mail.gmail.com> <353D5488-2054-4CE9-A029-3FE77D16FFCC@mackframework.com> <57a815bf0807232017q4fab6a05idb42dc67ff37df8c@mail.gmail.com> <57a815bf0807232111m6f0acd35uc689eb09f754035b@mail.gmail.com> <57a815bf0807232129uaa139bfjdfb131dd1b9b035d@mail.gmail.com> <89bd8880807240825j20a9ab80n88aacca5060877d6@mail.gmail.com> <57a815bf0807241719v5d1ff782mad86ac6c14173fd2@mail.gmail.com> Message-ID: <89bd8880807250856p738a5c1ep71a2c712c24d8ec4@mail.gmail.com> Hi Mikel, I'm currently monkey patching it in, with some code like: module TMail class Mail TO_TREE_INSPECT_DEFAULT = proc { |node| "#" } def to_tree io='', &inspect inspect ||= TO_TREE_INSPECT_DEFAULT io << "- #{inspect[self]}\n" recurse = proc do |node, prefix| if node.multipart? node.parts.each_with_index do |child, i| a, b = i == parts.length - 1 ? ["\\", ' '] : ['|', '| '] io << "#{prefix + a}- #{inspect[child]}\n" recurse.call child, prefix + b end end end recurse.call self, ' ' io end end end __END__ Feel free to redefine TO_TREE_INSPECT_DEFAULT as you see fit (or just switch it to :inspect.to_proc if you feel like making the default TMail::Mail#inspect a bit easier on the eyes). Thats just there for compatability with the custom message class I'm trying to replace with TMail. Usage is something like this to return a string: irb(main):133:0* puts mail.to_tree - # |- # | |- # | \- # \- # => nil Or you can stream directly to some IO object, and optionally override the string formation: irb(main):174:0> mail.to_tree(STDOUT) { |m| "#{m.content_type} (#{m.inspect[0, 50]}...)" } - multipart/mixed (# # On Thu, Jul 24, 2008 at 8:19 PM, Mikel Lindsaar wrote: > > On Fri, Jul 25, 2008 at 1:25 AM, charles wrote: > > irb(main):006:0> puts msg.to_mime.to_tree > > - # > > |- # > > | |- # > > | \- # > > \- # > > > > I've a patch somewhere that adds a similar "tree view" output to tmail > > objects which is helpful for debugging this stuff. > > Gimmie, I'll put it into the tree. That looks useful. > > -- > http://lindsaar.net/ > Rails, RSpec and Life blog.... > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk From raasdnil at gmail.com Sat Jul 26 08:26:00 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Sat, 26 Jul 2008 22:26:00 +1000 Subject: [Tmail-talk] Adding attachments In-Reply-To: <89bd8880807250856p738a5c1ep71a2c712c24d8ec4@mail.gmail.com> References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> <353D5488-2054-4CE9-A029-3FE77D16FFCC@mackframework.com> <57a815bf0807232017q4fab6a05idb42dc67ff37df8c@mail.gmail.com> <57a815bf0807232111m6f0acd35uc689eb09f754035b@mail.gmail.com> <57a815bf0807232129uaa139bfjdfb131dd1b9b035d@mail.gmail.com> <89bd8880807240825j20a9ab80n88aacca5060877d6@mail.gmail.com> <57a815bf0807241719v5d1ff782mad86ac6c14173fd2@mail.gmail.com> <89bd8880807250856p738a5c1ep71a2c712c24d8ec4@mail.gmail.com> Message-ID: <57a815bf0807260526hc6b05d7k3989d7a7da584074@mail.gmail.com> Dear Charles, Thanks for that, I'll get it in. My next task for TMail is getting 1.9 compatibility nailed. 2.0 is going to be a re-write. I want to simplify a _lot_ of things in TMail. Anyone who is interested in helping, send me a yo! It will not be hard and heavy, TMail is really needed for Ruby, and the current implementation is a bit dated now. Anyway, thanks for the code. Mikel From aquasync at gmail.com Sat Jul 26 13:42:21 2008 From: aquasync at gmail.com (charles) Date: Sat, 26 Jul 2008 13:42:21 -0400 Subject: [Tmail-talk] Adding attachments In-Reply-To: <57a815bf0807260526hc6b05d7k3989d7a7da584074@mail.gmail.com> References: <838EFB7A-4621-44A6-B9D2-17C39159B44F@mackframework.com> <57a815bf0807232017q4fab6a05idb42dc67ff37df8c@mail.gmail.com> <57a815bf0807232111m6f0acd35uc689eb09f754035b@mail.gmail.com> <57a815bf0807232129uaa139bfjdfb131dd1b9b035d@mail.gmail.com> <89bd8880807240825j20a9ab80n88aacca5060877d6@mail.gmail.com> <57a815bf0807241719v5d1ff782mad86ac6c14173fd2@mail.gmail.com> <89bd8880807250856p738a5c1ep71a2c712c24d8ec4@mail.gmail.com> <57a815bf0807260526hc6b05d7k3989d7a7da584074@mail.gmail.com> Message-ID: <89bd8880807261042k46d3471bwd01411b84f4e0226@mail.gmail.com> I'd be interested in helping out with 2.0. Big rewrites seem risky though, might be better if we can just push the code gradually in the right direction. What are the main things you want to change? I'd like to clean up my IO patches, and replace the (at least it seems to me?) unnecessary "port" abstraction with plain IO objects. Example use case, is to create a TMail object from an arbitrary IO handle, from an email in a zip (eg zip/zipfilesystem), or wherever. Maybe a first step is to introduce an IOPort class. After that, I'd like to see tmail perform better with large emails - eg not holding an entire 20M attachment in memory raw, and base64 encoded, but using streaming and filters for encoding/decoding. On Sat, Jul 26, 2008 at 8:26 AM, Mikel Lindsaar wrote: > Dear Charles, > > Thanks for that, I'll get it in. > > My next task for TMail is getting 1.9 compatibility nailed. > > 2.0 is going to be a re-write. I want to simplify a _lot_ of things > in TMail. Anyone who is interested in helping, send me a yo! It will > not be hard and heavy, TMail is really needed for Ruby, and the > current implementation is a bit dated now. > > Anyway, thanks for the code. > > Mikel > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk > From raasdnil at gmail.com Sat Jul 26 22:56:54 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Sun, 27 Jul 2008 12:56:54 +1000 Subject: [Tmail-talk] TMail: Future Direction Message-ID: <57a815bf0807261956v43f212d3v49a71322978b6fae@mail.gmail.com> On Sun, Jul 27, 2008 at 3:42 AM, charles wrote: > I'd be interested in helping out with 2.0. Big rewrites seem risky > though, might be better if we can just push the code gradually in the > right direction. That's probably a better idea and more what I meant :) I mean big re-write in a few key areas. > What are the main things you want to change? Specifically, probably in order of priority: * Encodings. TMail works in several cases, but there are plenty that it doesn't... big5 and Chinese encodings tend to nuke it. The encoder was written from a Japanese viewpoint, needs more l18n work. TMail should be able to send and receive any language without failures. * Ruby 1.9 compatibility. I have started on this, and it works somewhat. I got it down to three failing tests. The big problem here is that 1.9 supports encodings and 1.8 does not. Right now, TMail sprinkles the encoding throughout the code base (mainly contained in a few points... but not neat). This needs to be extracted to an interface and all text manipulations go through this class that translates the encoding in and out. This is a fairly complex job and is going to take probably the most work. But we have to have 1.9 compatibility soon. * IO and speed up here. I think we can speed this up fairly well. Handling large mailboxes etc is a bit scary right now. I like some of your ideas. * Interface. TMail is too complex and does not make the simple case easy. You shouldn't REALLY need to know the MIME spec to assemble an email and send it. At the same time, you should be able to manually assemble an email if you want. Simple case easy, complex case possible viewpoint. * The Parse Tree. The one it is using is RACC. I haven't yet found anyone that really understands it who is willing to help out - and there are edge cases that it just breaks with that I have handled by sanitizing the input to the parser. Other parsers are available (Parse Tree maybe?), and it may also just be simpler to do this in plain Ruby split up into intelligent regex methods. Ruby regex has come a fair ways since TMail was written. Having our extensive test base would help with this. On the interface, I want to clean it up a lot. The simple task of sending an email with an attachment should be simple and obvious. require 'tmail' TMail::Mail.config({:smtp => 127.0.0.1}) TMail::Mail.send do from 'me at me.com' to 'you at you.com' subject 'This should be easy' multipart true text_body my_plain_text html_body my_html_text add_file('This is the first attachment', '/path/to/my.jpg') add_file('This is the second attachment', path_to_file, 'text/unknown-type') end And it just goes ahead and builds the email and sends it, wrapping Net::SMTP. Receiving should be as easy.... > I'd like to clean up my IO patches, and replace the (at least it seems > to me?) unnecessary "port" abstraction with plain IO objects. Example > use case, is to create a TMail object from an arbitrary IO handle, > from an email in a zip (eg zip/zipfilesystem), or wherever. Maybe a > first step is to introduce an IOPort class. That's a good idea. TMail has a bunch of different strategies that it uses to read in email. I'd like to simplify this a bit as it gets really painful with encodings. > After that, I'd like to see tmail perform better with large emails - > eg not holding an entire 20M attachment in memory raw, and base64 > encoded, but using streaming and filters for encoding/decoding. Right. I think we are on the same track and I would appreciate your help. Anyone else on the list have suggestions? Mikel -- http://lindsaar.net/ Rails, RSpec and Life blog.... From mark at mackframework.com Sat Jul 26 23:21:46 2008 From: mark at mackframework.com (Mark Bates) Date: Sat, 26 Jul 2008 23:21:46 -0400 Subject: [Tmail-talk] TMail: Future Direction In-Reply-To: <57a815bf0807261956v43f212d3v49a71322978b6fae@mail.gmail.com> References: <57a815bf0807261956v43f212d3v49a71322978b6fae@mail.gmail.com> Message-ID: <67F92FF2-C31B-4E96-AC52-5FDCC0B953B1@mackframework.com> Mikel, the biggest thing, for me at least, in TMail 2.0 would definitely be the interface. I recently have been wrapping it so I could add a mailer gem to the Mack framework, and I found it terribly confusing. It's very feature rich, but constructing simple emails, is a bit cumbersome, and non-intuitive. What I've done for Mack is created a very simple interface for creating emails that should be very easy for people to use and I've wrapped that around an adapter to TMail. If you'd like to look at the interface, it's at: http://github.com/markbates/mack-more/tree/master/mack-mailer/lib/mack-mailer/mailer.rb The usage of it looks like this: http://gist.github.com/2712 Now, of course I'm doing a few things under the covers as far as configuration is concerned, but the point is it should be as possible, but allow for people to get in there and really mix it up. Just my $.02. TMail is a great Mailing framework, but it definitely could be easier to use. :) ------------------------------------------------------------------------------------------------- Mark Bates mark at mackframework.com http://www.mackframework.com http://api.mackframework.com/ http://github.com/markbates/mack On Jul 26, 2008, at 10:56 PM, Mikel Lindsaar wrote: > On Sun, Jul 27, 2008 at 3:42 AM, charles wrote: >> I'd be interested in helping out with 2.0. Big rewrites seem risky >> though, might be better if we can just push the code gradually in the >> right direction. > > That's probably a better idea and more what I meant :) I mean big > re-write in a few key areas. > >> What are the main things you want to change? > > Specifically, probably in order of priority: > > * Encodings. TMail works in several cases, but there are plenty that > it doesn't... big5 and Chinese encodings tend to nuke it. The encoder > was written from a Japanese viewpoint, needs more l18n work. TMail > should be able to send and receive any language without failures. > > * Ruby 1.9 compatibility. I have started on this, and it works > somewhat. I got it down to three failing tests. The big problem here > is that 1.9 supports encodings and 1.8 does not. Right now, TMail > sprinkles the encoding throughout the code base (mainly contained in a > few points... but not neat). This needs to be extracted to an > interface and all text manipulations go through this class that > translates the encoding in and out. This is a fairly complex job and > is going to take probably the most work. But we have to have 1.9 > compatibility soon. > > * IO and speed up here. I think we can speed this up fairly well. > Handling large mailboxes etc is a bit scary right now. I like some of > your ideas. > > * Interface. TMail is too complex and does not make the simple case > easy. You shouldn't REALLY need to know the MIME spec to assemble an > email and send it. At the same time, you should be able to manually > assemble an email if you want. Simple case easy, complex case > possible viewpoint. > > * The Parse Tree. The one it is using is RACC. I haven't yet found > anyone that really understands it who is willing to help out - and > there are edge cases that it just breaks with that I have handled by > sanitizing the input to the parser. Other parsers are available > (Parse Tree maybe?), and it may also just be simpler to do this in > plain Ruby split up into intelligent regex methods. Ruby regex has > come a fair ways since TMail was written. Having our extensive test > base would help with this. > > On the interface, I want to clean it up a lot. The simple task of > sending an email with an attachment should be simple and obvious. > > require 'tmail' > TMail::Mail.config({:smtp => 127.0.0.1}) > > TMail::Mail.send do > from 'me at me.com' > to 'you at you.com' > subject 'This should be easy' > multipart true > text_body my_plain_text > html_body my_html_text > add_file('This is the first attachment', '/path/to/my.jpg') > add_file('This is the second attachment', path_to_file, 'text/ > unknown-type') > end > > And it just goes ahead and builds the email and sends it, wrapping > Net::SMTP. > > Receiving should be as easy.... > >> I'd like to clean up my IO patches, and replace the (at least it >> seems >> to me?) unnecessary "port" abstraction with plain IO objects. Example >> use case, is to create a TMail object from an arbitrary IO handle, >> from an email in a zip (eg zip/zipfilesystem), or wherever. Maybe a >> first step is to introduce an IOPort class. > > That's a good idea. TMail has a bunch of different strategies that it > uses to read in email. I'd like to simplify this a bit as it gets > really painful with encodings. > >> After that, I'd like to see tmail perform better with large emails - >> eg not holding an entire 20M attachment in memory raw, and base64 >> encoded, but using streaming and filters for encoding/decoding. > > Right. I think we are on the same track and I would appreciate your > help. Anyone else on the list have suggestions? > > Mikel > > > -- > http://lindsaar.net/ > Rails, RSpec and Life blog.... > _______________________________________________ > Tmail-talk mailing list > Tmail-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/tmail-talk From riddochc at gmail.com Mon Jul 28 00:23:49 2008 From: riddochc at gmail.com (Chris Riddoch) Date: Sun, 27 Jul 2008 22:23:49 -0600 Subject: [Tmail-talk] TMail: Future Direction In-Reply-To: <57a815bf0807261956v43f212d3v49a71322978b6fae@mail.gmail.com> References: <57a815bf0807261956v43f212d3v49a71322978b6fae@mail.gmail.com> Message-ID: <6efbd9b70807272123h7f349f6ar898f993e37111d3c@mail.gmail.com> On 7/26/08, Mikel Lindsaar wrote: > * The Parse Tree. The one it is using is RACC. I haven't yet found > anyone that really understands it who is willing to help out - and > there are edge cases that it just breaks with that I have handled by > sanitizing the input to the parser. Other parsers are available > (Parse Tree maybe?), and it may also just be simpler to do this in > plain Ruby split up into intelligent regex methods. Ruby regex has > come a fair ways since TMail was written. Having our extensive test > base would help with this. It's worth mentioning that Ragel is a very nice parser-generator system, and its website[1] mentions a mailbox and mail message parser already written in it[2] that could be a starting point, if not a good solution outright. [1] http://research.cs.queensu.ca/~thurston/ragel/ [2] http://research.cs.queensu.ca/~thurston/ragel/examples/mailbox.rl -- epistemological humility Chris Riddoch From lists at kikobu.com Tue Jul 29 04:06:50 2008 From: lists at kikobu.com (Morten) Date: Tue, 29 Jul 2008 10:06:50 +0200 Subject: [Tmail-talk] Is this correct? In-Reply-To: <57a815bf0807241720t2b6b561pee3e11cad77975cc@mail.gmail.com> References: <462BA556-7D9D-498E-861A-73F5DB0D4A5A@kikobu.com> <57a815bf0807241720t2b6b561pee3e11cad77975cc@mail.gmail.com> Message-ID: <5DB70336-B603-4257-ADDF-871D022C7A26@kikobu.com> On Jul 25, 2008, at 2:20 AM, Mikel Lindsaar wrote: > On Fri, Jul 25, 2008 at 5:47 AM, Morten wrote: >>>> TMail::Address.parse('no_valid_email') >> => # >> >> I know that you have a massive test repository, but I'm just >> surprised that >> an email address doesn't have to contain an @ > > Yes, you can send email to another person on your system without an > email address. The SMTP gateway will attempt to deliver it locally. Ah, I'd completely forgotten about that. Thanks. How about this one: >> TMail::Address.parse('hans at foo.com ').address => "hans at foo.com" Is it intended that the parser rewrites the value? The trailing white space is not a problem? I know that this is an edge case - our usage is "if the email is valid per tmail, save it to the DB" then later when we get an incoming mail with that address, we're not able to find it as the parsed value does not contain the whitespace (natrually). Easy enough to work around, I'm just here due to curiosity :-) Br, Morten From raasdnil at gmail.com Tue Jul 29 20:55:25 2008 From: raasdnil at gmail.com (Mikel Lindsaar) Date: Wed, 30 Jul 2008 10:55:25 +1000 Subject: [Tmail-talk] Is this correct? In-Reply-To: <5DB70336-B603-4257-ADDF-871D022C7A26@kikobu.com> References: <462BA556-7D9D-498E-861A-73F5DB0D4A5A@kikobu.com> <57a815bf0807241720t2b6b561pee3e11cad77975cc@mail.gmail.com> <5DB70336-B603-4257-ADDF-871D022C7A26@kikobu.com> Message-ID: <57a815bf0807291755j7e93cc36m30ad336e4ae67273@mail.gmail.com> > Ah, I'd completely forgotten about that. Thanks. > How about this one: > >>> TMail::Address.parse('hans at foo.com ').address > => "hans at foo.com" > > Is it intended that the parser rewrites the value? The trailing white space > is not a problem? I know that this is an edge case - our usage is "if the > email is valid per tmail, save it to the DB" then later when we get an > incoming mail with that address, we're not able to find it as the parsed > value does not contain the whitespace (natrually). Easy enough to work > around, I'm just here due to curiosity :-) Well, trailing whitespace is ignored on the email line per the RFCs, so that's what you would be hitting there. I would take the tmail address object and take it's output and pump that into your database. Get's rid of all sorts of unwanted guff too... like trailing white space :) Mikel -- http://lindsaar.net/ Rails, RSpec and Life blog....