Reputation: 18382
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.
Upvotes: 10
Views: 11195
Reputation: 21477
Another excellent solution is a gem called pony. It is exactly like php's mail() function. Simply and easy.
Upvotes: 4
Reputation: 5486
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.
Upvotes: 0
Reputation: 1452
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
Upvotes: 11
Reputation: 123662
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
Upvotes: 13
Reputation: 2947
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
Upvotes: 3