First, login to your SendGrid account and generate a new api key. Give it the appropriate permissions for your app. https://app.sendgrid.com/settings/api_keys
Then edit your config/environments/production.rb
file.
From something like this:
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USER_NAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'heroku.com',
:enable_starttls_auto => true}
To this:
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => 'apikey',
:password => ENV['SENDGRID_API_KEY'],
:domain => 'heroku.com',
:enable_starttls_auto => true}
Notice we change the user_name to 'apikey', and password to the api key stored in your environment variables.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…