Using SendGrid with Ruby on Cloud9



I have followed the very brief instructions here to enable a Ruby application to send email, but it doesn’t seem to be working, although there is no error message, so it’s a little hard to debug.

Here are my steps in trying to get email to work within Ruby:

1. I obtained Sendgrid user-name and password.
2. I generated an action mailer using $ rails generate mailer TestMailer
3. I created a TestMailer class with a send_email method. In app/mailers/test_mailer.rb:

class TestMailer < ActionMailer::Base
  def send_email
    mail( :to => "",
    :subject => 'Just a test' )


4. I configured my ActionMailer to use SendGrid. In config/environment.rb I added:

ActionMailer::Base.smtp_settings = {
    :user_name => [my Sendgrid username],
    :password => [my Sendgrid password],
    :domain => ',
    :address => '',
    :port => 2525,
    :authentication => :plain,
    :enable_starttls_auto => true

5. I tested by using rails console


I got an immediate response:

TestMailer#send_email: processed outbound mail in 60.2ms
=> #<ActionMailer::MessageDelivery:0x20c3030>

which sounds like it worked, but I never received the email (yes, I checked my Spam folder).

Has anyone who has used SendGrid email from within Ruby on Cloud9? Can you give me any hints as to what might be going wrong?


There are a couple of places where I’m not sure that I did the right thing. I’m not sure what “domain” to use:, or the domain of my Cloud9 workspace, or what?


I realize that there is another step to deliver the mail: You create a mail object (in the console) using mail = TestMailer.send_email and then you can deliver it by doing mail.deliver_now. That requires creating a template for send_email. But in any case, it still doesn’t work. The email never shows up.


I am not sure if you ever resolved your issue, but I am having some similar issues. My debugging shows that the send mail timesout after 30 seconds. This is only in my development environment, when I push to Heroku the code does work. I suspect the issue is with the domain, and the personalized c9 url may be looking for authentication. I am working through the issues now so if I find a resolutionI will post it


Apparently Cloud 9 blocks SMTP