70. Contact Mailer File

  • To have our Rails app send out emails, we need to add some code to a Mailer file.
  • This is the default way you can make a Rails app send out emails.

###Terminal

touch app/mailers/contact_mailer.rb

###app/mailers/contact_mailer.rb

class ContactMailer < ActionMailer::Base
  default to: '[email protected]'
  def contact_email(name, email, body)
    @name = name
    @email = email
    @body = body
    mail(from: email, subject: 'Contact Form Message')
  end
end

###Terminal

git status
git add .
git commit -m "Added contact form mailer file"
git push origin contact_form

Complete and Continue