Rails mailer without view
I found the way by experimentation :
mail(:to => email, :subject => 'we found the answer') do |format|
format.text do
render :text => '42 owns the World'
end
end
This is also said in the Rails Guide : http://guides.rubyonrails.org/action_mailer_basics.html at section 2.4
Much simpler, just use the body option :
def welcome(user)
mail to: user.email,
from: "\"John\" <[email protected]>",
subject: 'Welcome in my site',
body: 'Welcome, ...'
end
And if you plan to use html, don't forget to specify that with the content_type option which is by default text/plain.
content_type: "text/html"
So with body option rails skips the template rendering step.