Implementing SendGrid in your Environment

Note: This article supersedes our now legacy SendGrid Add-on and should be used as the method to integrate SendGrid into your application. This method applies to our stable-v5 stack and higher, if you are on a lower stack version than this please contact our Support team.

 

SendGrid can easily be integrated into your applications by obtaining SG sending credentials and setting these as Environment Variables via the EY Cloud dashboard, then sourcing these in your application's configuration.

 

Part 1: SendGrid

  1. Head to https://app.sendgrid.com/login and create a new account if you do not have one yet. If you do, log in
  2. Once in your account click on Settings > API Keys
  3. Click Create Key and enter a name for your API key, ideally related to the application & environment it will be used on for ease of future reference
  4. Once you have your key, copy it and make sure you have it saved for a later point. Important: keys cannot be viewed again after this point

Part 2: EY Cloud

  1. Modify your config/environments/production.rb by adding the following: (Make sure to replace "yourdomain.com" with the domain you will be sending the email from, all other values should be left as-is).
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.perform_deliveries = true
    config.action_mailer.raise_delivery_errors = true
    config.action_mailer.smtp_settings = {
         :authentication => :plain,
         :address => "smtp.sendgrid.net",
         :port => 587,
         :domain => "yourdomain.com",
         :user_name => "apikey",
         :password => ENV['SENDGRID_API_KEY'],
         :authentication => 'plain',
         :enable_starttls_auto => true 
    }
    
  2. Push the changes to your code onto the repo where it is hosted
  3. Add your API key from Step 4 of Part 1 to the Environment Variables for your environment, calling it SENDGRID_API_KEY. The Environment Variables page is linked from under More Options on the Environment page of the EY dashboard
  4. Apply the changes to your environment so that environment variable are pushed to the instances and the key is accessible by your app
  5. Deploy your application

And that's it! You should be ready to use SendGrid with EngineYard Cloud.

Comments

Article is closed for comments.