What is the simplest way to send mail using Ruby on Rails? Is there a way to send mail directly via ruby and skip all the rails models and complexity, just like php's mail() function?
Thanks for your help.
What is the simplest way to send mail using Ruby on Rails? Is there a way to send mail directly via ruby and skip all the rails models and complexity, just like php's mail() function?
Thanks for your help.
yes check out the ruby docs...http://ruby-doc.org/stdlib/
the package you want to look at is net/smtp
there is also
http://www.rfc20.org/rubymail/(ruby mail) which is popular and make it a little easier
The simplest way in plain old ruby is to use net/smtp. However rails has it's own built in mailing facilities, because sending mail is something that is pretty common. The best way to do it in rails, is to use a Mailer model
Make sure you replace all the example.com's with real values:
require 'net/smtp'
Net::SMTP.start('smtp.example.com', 25) do |smtp|
smtp.send_message "Subject: testing from ruby", '[email protected]', ['[email protected]', '[email protected]']
end
I'm concerned that if you don't want to use ActionMailer that maybe you just don't get rails. ActionMailer makes sending email with good templating and the like very very easy, you really should look into it.