/actionmailer_basics

A lesson that students will use to learn ActionMailer basics.

Primary LanguageRuby

ActionMailer Basics

Goal

The goal of this repository is to give students a place where they can learn about ActionMailer. There will be no lecture on this material before the homework. Students can use the ActionMailer guide to help them along. Students will bring questions to class the next day that we can answer for them.

Setup

  1. Fork and clone the repository
  2. Install gems using bundle install
  3. Create and migrate the databases using rake db:create:all db:migrate
  4. Run all of the specs using rake spec or rspec

Assignment

Get all of the specs passing. If you get stuck, check out the solutions branch to help you along. Bring your questions to class the next day.

Viewing emails while doing development

While you are doing development, you may want to be able to actually see the emails that are getting sent from your app. You can install the MailCatcher gem.

You can also need to add the following to your config/environment/development.rb file:

config.action_mailer.default_url_options = {host: "localhost:3000"}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {:address => "localhost", :port => 1025}

Using ActionMailer on Heroku

  1. Install the SendGrid add-on
  2. Add the following to your config/environment/production.rb file:
config.action_mailer.default_url_options = { host: "<the domain of your application>"}
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address        => 'smtp.sendgrid.net',
  :port           => '587',
  :authentication => :plain,
  :user_name      => ENV['SENDGRID_USERNAME'],
  :password       => ENV['SENDGRID_PASSWORD'],
  :domain         => 'heroku.com',
  :enable_starttls_auto => true
}