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.
Action Mailer allows you to send emails using mailer classes and views. Mailers work very similarly to controllers.
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
There's also TMail.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With