Skip to main content

Posts

Showing posts with the label send mail

Sending Emails in Rails Applications

Action Mailer is the Rails component that enables applications to send and receive emails. In Rails, emails are used by creating mailers that inherit from “ActionMailer::Base” in app/mailers. Those mailers have associated views that appear alongside controller views in app/views. Now we will build a rails application which will send an email to the user when a new user is created. Let’s create a new rails application. $ rails new sample_app $ cd sample_app $ rails generate scaffold user first_name:string last_name:string phone_number:string email:string $ rake db:migrate Action Mailer- Configuration: Following are the steps you have to follow to complete your configuration before proceeding with the actual work. We will just add following lines of code in  config/environments/development.rb config.action_mailer.delivery_method = :smtp #It tells ActionMailer that you want to use the SMTP server. Generate a Mailer : We now have a basic application, let’s make ...