Ruby on Rails - generating a new mailer in ruby on rails- ruby on rails tutorial - rails guides - rails tutorial - ruby rails
How to generate a new mailer
Enter the given below command to generate newmailer.
rails generate mailer PostMailer
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
This will generate a blank template file in app/mailers/post_mailer.rb named PostMailer
class PostMailer < ApplicationMailer
end
Clicking "Copy Code" button will copy the code into the clipboard - memory. Please paste(Ctrl+V) it in your destination. The code will get pasted. Happy coding from Wikitechy - ruby on rails tutorial - rails guides - ruby rails - rubyonrails - learn ruby on rails - team
- Two layout files will also be generated for the email view, one for the html format and one for the text format.
- If we prefer not to use the generator, we can create our own mailers. Make sure they inherit from ActionMailer::Basefiles: