if Rails.env.staging? || Rails.env.production?
  SMTP_SETTINGS = {
    address: ENV.fetch('SMTP_ADDRESS'), # example: 'smtp.sendgrid.net'
    authentication: :plain,
    domain: ENV.fetch('SMTP_DOMAIN'), # example: 'this-app.com'
    password: ENV.fetch('SMTP_PASSWORD'),
    port: '587',
    user_name: ENV.fetch('SMTP_USERNAME')
  }
end

if Rails.env.staging? || Rails.env.production?
  SMTP_SETTINGS = {
    address: ENV.fetch('SMTP_ADDRESS'), # example: 'smtp.sendgrid.net'
    authentication: :plain,
    domain: ENV.fetch('SMTP_DOMAIN'), # example: 'this-app.com'
    enable_starttls_auto: true,
    password: ENV.fetch('SMTP_PASSWORD'),
    port: '587',
    user_name: ENV.fetch('SMTP_USERNAME')
  }
end

Enable SMTP/TLS in SMTP settings
Enable SMTP/TLS in SMTP settings

Be more secure by default.

https://en.wikipedia.org/wiki/STARTTLS

Recommended by SendGrid, our usual email provider.

http://sendgrid.com/docs/Integrate/Frameworks/rubyonrails.html
