From: Kevin Smith Date: 2000-12-14T11:03:48+09:00 Subject: [ruby-talk:7185] Re: Sending SMTP (was: Re: Hello and a question.) >Kevin Smith writes: > >> Here's my SMTP code (that works): >> >> smtp = Net::SMTP.start('mail.server.whatever') >> smtp.ready(from, to) do >> | a | >> message.each do >> | line | >> a.write(x + "\r\n") >> $stdout.write(x + "\r\n") #debugging >> end >> end > >In fact, that can be even simpler (but without the debugging) using > > Net::SMTP.start(server) do |smtp| > smtp.sendmail(message, from, [ to ]) > end > >Down in the guts of protocol.rb the code will add \r\n to lines that >are missing them. All 'message' has to do is respond to 'each'. Thanks for the tip. My original implementation assumed that message was an array, not a string. I rewrote it using your approach, and using a string with "\n" terminated lines, and it seems to work fine. Kevin