Sunday, July 01, 2018

Sending email in production in Rails apps

In controller:

PurchaseNotifierMailer.send_purchase_confirmation_email(@user).deliver!

In production.rb:

config.action_mailer.smtp_settings = {
  user_name: 'sendgridusername',
  password: 'sendgridpassword',
  domain: 'yourdomain.com',
  address: 'smtp.sendgrid.net',
  port: 587,
  authentication: :plain,
  enable_starttls_auto: true
}