title: How to configure Devise email with Heroku and Sendgrid in Rails?
body: <p>I've got a simple Rails 3.2.7 app with Devise added that is deployed to Heroku with Sendgrid added. It works fine on heroku for everything except when it needs to do a password retrieve which requires sending an email. From all the posts i have read i suspect i am somehow setting up the mail parameters incorrectly. Any suggestions are appreciated.</p>
  
  <p>For config/environments/production.rb i added</p>
  
  <pre><code>config.action_mailer.default_url_options = { :host =&gt; 'smtp.sendgrid.net'} 
  </code></pre>
  
  <p>for config/initializers/devise.rb i added</p>
  
  <pre><code>config.mailer_sender = "mail-to-send@from.com"
  </code></pre>
  
  <p>and for config/environments.rb i added</p>
  
  <pre><code>ActionMailer::Base.smtp_settings = {
  :address        =&gt; 'smtp.sendgrid.net',
  :port           =&gt; '587',
  :authentication =&gt; :plain,
  :user_name      =&gt; ENV['SENDGRID_USERNAME'],
  :password       =&gt; ENV['SENDGRID_PASSWORD'],
  :domain         =&gt; 'heroku.com',
  :enable_starttls_auto =&gt; true
  }
  </code></pre>