[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Bug in open_message_stream of Net::SMTP?

Lars Hoss

1/26/2005 1:34:00 PM

Hi all!

The following sample code doesn't work for me:

Net::SMTP.start("smtp.mac.com", 25) do |smtp|
smtp.open_message_stream(from_addr, [to_addr]) do |f|
f.puts "Subject: test message"
f.puts
f.puts "This is a test message"
end
end

This is the result:
-----------------------------------------
From woeye@mac.com Wed Jan 26 14:20:35 2005
Return-path: <woeye@mac.com>
... snip
Message-id: <200501261320.j0QDKIwD007784@mac.com>
Original-recipient: rfc822;woeye@mac.com



Subject: test message

This is a test message
-----------------------------------------

I wonder where the empty lines after the "Original-recipient" come from?
Using send_message, however, works fine:

msgstr = <<EOF
Subject: test message

This is a test message
EOF

Net::SMTP.start("smtp.mac.com", 25) do |smtp|
smtp.send_message msgstr, from_addr, to_addr
end

Regards,
Lars



2 Answers

Minero Aoki

1/26/2005 2:10:00 PM

0

Lars Hoss

1/26/2005 2:58:00 PM

0

Thanks for the quick feedback. I simply was puzzled wether I it was
mine or Net::SMTP's failure :-)

Regards,
Lars

> Sorry, I forgot to backport a patch from 1.9.
> Use this patch:
>
> --- lib/net/protocol.rb 18 Aug 2004 14:42:04 -0000 1.73.2.1
> +++ lib/net/protocol.rb 26 Jan 2005 14:06:47 -0000
> @@ -403,7 +403,7 @@
> end
>
> def puts( str = '' )
> - write str.sub(/\n?/, "\n")
> + write str.chomp("\n") + "\n"
> end
>
> def printf( *args )
>
>
> Regards,
> Minero Aoki
>
>
--
"Stil ist die Fähigkeit, komplizierte Dinge einfach zu sagen - nicht
umgekehrt." -- Cocteau, Jean