78. Sending Email with Mailgun

  • There are many third-party addon services that can be used to manage email sending.
  • We'll rent the email servers from Mailgun.
  • You will need to put a credit card on file, although you will never be charged unless you manually choose to upgrade your account.
  • While this step is optional, it will show you how to integrate a mail server service into your Heroku account. Without completing this step, your application will work, but will not actually send out emails, even though you'll have coded all the necessary features for email sending.


heroku addons:create mailgun:starter
(You should be prompted to verify card information at heroku.com/verify)
heroku addons:create mailgun:starter
heroku domains


ActionMailer::Base.smtp_settings = {
  :port           => ENV['MAILGUN_SMTP_PORT'],
  :address        => ENV['MAILGUN_SMTP_SERVER'],
  :user_name      => ENV['MAILGUN_SMTP_LOGIN'],
  :password       => ENV['MAILGUN_SMTP_PASSWORD'],
  :domain         => 'shrouded-fortress-66409.herokuapp.com',
  :authentication => :plain,
ActionMailer::Base.delivery_method = :smtp


git add .
git commit -m "Added mailer settings to environment file"
git push origin master
git push heroku master

Complete and Continue