How can I send an email in one line without creating a mailer class?
I need to set all the params including :from (which is different than the smtp user)
So far I got this:
# ok not exactly a one liner, but it doesn't matter
ActionMailer::Base.mail(:from => '[email protected]', :to => '[email protected]', :subject => 'subject bla') do
'content bla'
end.deliver
The content is not working, I receive a blank email
1 Introduction. Action Mailer allows you to send emails from your application using a mailer model and views. So, in Rails, emails are used by creating mailers that inherit from ActionMailer::Base and live in app/mailers. Those mailers have associated views that appear alongside controller views in app/views.
ActionMailer::Base.mail(from: '[email protected]', to: '[email protected]', subject: "Welcome to My Awesome Site", body: 'I am the email body.').deliver
Omg, we have one-liner!
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