From: Reimer Behrends Date: 2004-01-04T05:26:46+09:00 Subject: Re: Best way to send mail in ruby Bauduin Raphael (rb@raphinou.com) wrote: [...] > So, do I have to combine both to send a mail? Isn't there simply > something like > > Mail::send_mail(from, to, subject, body) ? Assuming that you have sendmail/exim/postfix or something else with sendmail-compatible options on your system (which is pretty much any UNIX MTA), the script below should suffice. The -oi option prevents a line with a single dot to be interpreted as the end of the message; the -t option tells the MTA to extract the To address from the headers; the -oem message tells the mailer to deliver an error message to the sender if the command fails; and -odb delivers the message in the background rather than suspending the calling process. You may have to change the path to /usr/sbin/sendmail on some systems. Reimer Behrends SENDMAIL = "/usr/lib/sendmail -oi -t -oem -odb" def sendmail(from, to, subject, body) File.popen(SENDMAIL, "w") do | pipe | pipe.puts "From: #{from}" pipe.puts "To: #{to}" pipe.puts "Subject: #{subject}" pipe.puts pipe.puts body end end