Does SendGrid work from Digital Ocean droplet (Ubuntu 14.04 x64)?

Posted April 6, 2015 8.3k views
UbuntuPHPDigitalOceanPHP Frameworks

Hi there,
I have just set up a droptet on Ubuntu 14.04 and now trying to work with SendGrid api to send emails, but it does not work. Can someone tell me if can use SendGrid from Digital Ocean server? If so, can you please let me know if there is any configuration needed or if you can share some sample code? Thanks.

  • Hi! There’s no reason why SendGrid shouldn’t work as normal on a droplet. Are you seeing any errors from the API? Could you post a snippet of your code? Any additional info that you could provide would help us get to the bottom of the problem.

  • I have the same question.
    In my case I have a rails application and have used the action mailer. So I have generated a mail and have configured mailers for sending a password reset, confirm sign in and contact us.
    Example: this link
    It also shows configuration settings to point to SendGrid’s servers

    What I am confused about is.. do we need to add SMTP servers (like Postfix/Dovecot, which is quite a pain) or can we use sendgrid on its own?

    The instructions for the API are different

    I have been following a tutorial from Michael Hartl but he directs the reader to Heroku and it looks like Heroku has sendgrid as a standard set up. His tutorial uses the mailers and framework.

    If there is any info on Sendgrid (Rails) .. step by step. That would be awesome. I also reached out to Sendgrid. If I learn more I will post it.

  • I got it to work by doing:

    1. Added: gem ‘sendgrid’ to my gemfile

    2. Edited /etc/default/unicorn and added

      export SENDGRID_USERNAME='username'
      export SENDGRID_PASSWORD='password'
    3. $ service unicorn restart && service nginx reload

    4. Edited config/environments/production.rb and added:

      config.action_mailer.raise_delivery_errors = true
      config.action_mailer.delivery_method = :smtp
      host = ''
      config.action_mailer.default_url_options = { host: host }
      ActionMailer::Base.smtp_settings = {
      :address        => '',
      :port           => '587',
      :authentication => :plain,
      :user_name      => ENV['SENDGRID_USERNAME'],
      :password       => ENV['SENDGRID_PASSWORD'],
      :domain         => '',
      :enable_starttls_auto => true

    I also had an issue where my password had spaces, apparently that caused an issue, so I created a new one (by creating a new credentials on sendgrid) without spaces and it worked perfectly.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

I Estou setting server to validate com Send Grid white label do, but do configuação na tem DNS returned unto me seguinte erros:

Error validating domain:
Expected CNAME for “” to match “”.
Expected CNAME for “s2.” to match “”.

Can you help me


  • your CNAME in your DNS registry should be like hostname: “” value: “”.
    In most of the dns websites, in hostname you only have to add “s1.domainkey” the “” will automatically added(but better to check the config after saving). Sendgrid usually needs 3 CNAMES.