Thanks :-)

I wonder if there's a central place (liek a ruby classes repository)
where one could look for such things, rather than everybody rewriting
all this for their own need ( I thought about writing similar code,
but thought it was already existing and prefered to use a
well tested solution)

Or am I wrong in thinking that lots of those little code snippets
have been  written times and times again by developers for their own
needs?

Wouldn't such a classes repository be helpfull?


Raph

PS: I'm still new to Ruby, and  may have a wrong impression... Just
trying to be constructive ;-)


Reimer Behrends wrote:
> 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