Niklaus Giger
2008-Mar-31 06:01 UTC
[Tmail-talk] Errors migrating to tmail 1.2.1 (from << 0.11)
Hi I used tmail with much success in a small utility at the enterprise where I work. Thanks a lot for this nice library! I wrote it more than two years ago. As our server will be migrated I have to switch to newer version of ruby and tmail. Almost all my unit tests passed once I did a few cleanups like - msgid -> message_id - from_addresses -> from_addrs I however failed to create test messages where I before did things like mail.parts[0] = <some content> I tried various things but could not figure out the correct way to setup a multiple part for a test message, where I have a) a part with some text b) one or more attachements (e.g. zip files) I would appreciate if somebody could outline me how to do this. Best regards and thanks in advance. Niklaus -- Niklaus Giger Wieshoschet 6 CH-8753 Mollis Tel. ++41 55 612 20 54 (privat) Tel. ++41 55 618 64 68 (Gesch?ft)
Mikel Lindsaar
2008-Mar-31 09:52 UTC
[Tmail-talk] Errors migrating to tmail 1.2.1 (from << 0.11)
On Mon, Mar 31, 2008 at 5:01 PM, Niklaus Giger <niklaus.giger at member.fsf.org> wrote:> I used tmail with much success in a small utility at the enterprise where I work. > Thanks a lot for this nice library!You are very welcome> I however failed to create test messages where I before did things like > mail.parts[0] = <some content>The simple way is just make a new tmail object set it''s body etc and then add that to the parts array.. Here is an irb transcript of the process: irb(main):001:0> require ''tmail'' => true irb(main):003:0* mail = TMail::Mail.new => #<TMail::Mail port=#<TMail::StringPort:id=0x2b8e00> bodyport=nil> irb(main):002:0> mail.to = ''mikel at me.com'' => "mikel at me.com" irb(main):004:0> part1 = TMail::Mail.new => #<TMail::Mail port=#<TMail::StringPort:id=0x2b7ad2> bodyport=nil> irb(main):005:0> part1.body = "This is a plain text part" => "This is a plain text part" irb(main):006:0> part1.content_type = ''text/plain'' => "text/plain" irb(main):007:0> part1.to_s => "Content-Type: text/plain\n\nThis is a plain text part" irb(main):008:0> mail.parts[0] = part1 => #<TMail::Mail port=#<TMail::StringPort:id=0x2b7ad2> bodyport=#<TMail::StringPort:id=0x2b6240>> irb(main):009:0> puts mail.encoded To: mikel at me.com Content-Type: multipart/mixed; boundary=mimepart_47f0b415efcf7_1b9fbb8036f --mimepart_47f0b415efcf7_1b9fbb8036f Content-Type: text/plain This is a plain text part --mimepart_47f0b415efcf7_1b9fbb8036f-- => nil