Question

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

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.

Subscribe
Share

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'
  1. $ service unicorn restart && service nginx reload
  2. Edited config/environments/production.rb and added:
  config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  host = 'domain.com'
  config.action_mailer.default_url_options = { host: host }
  ActionMailer::Base.smtp_settings = {
    :address        => 'smtp.sendgrid.net',
    :port           => '587',
    :authentication => :plain,
    :user_name      => ENV['SENDGRID_USERNAME'],
    :password       => ENV['SENDGRID_PASSWORD'],
    :domain         => 'domain.com',
    :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.

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 https://sendgrid.com/docs/Integrate/Frameworks/rubyonrails.html 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 https://github.com/sendgrid/sendgrid-ruby https://sendgrid.com/docs/API_Reference/Web_API/mail.html

I have been following a tutorial from Michael Hartl https://www.railstutorial.org/ 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.

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.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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 “s1._domainkey.pyknet.info” to match “s1.domainkey.u2128219.wl.sendgrid.net”. Expected CNAME for “s2._domainkey.pyknet.info” to match “s2.domainkey.u2128219.wl.sendgrid.net”.

Can you help me

Paulo