Can't send email from workspace


#1

Hi I need to have SMTP from my Cloud9 rails app so that I can test some email functionality.

I have signed up for Mailgun, as I thought that they would be allowed on port 2525.

I am not having any luck with this.

When I try to send to port 587, I’m getting Net::OpenTimeout: execution expired error, when I change it to 2525, I’m getting OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=unknown state: unknown protocol

The strange thing is that when I run the mail applications in IRB, they all work.

Please could you supply a few ‘how-to’ details on Cloud9 workspaces, Sending email on Google Compute Engine.

Has anyone actually made this work?

Thanks

Tom


How can I send email from my app?
#2

By the way, Sendgrid simple SMTP does not work either from Cloud9 IDE


#3

Please post the error messages you’re receiving along with the relevant code snippet you’re using to configure SMTP (hide any secret keys etc, as this is a public forum).


#4

Hi

I’ve already posted the error messages above. Here is my SMTP configuration in the rails app.

config.action_mailer.raise_delivery_errors = true config.action_mailer.perform_deliveries = true config.action_mailer.delivery_method = :smtp config.action_mailer.default_url_options = { :host => '<MY_APP>-tomgallagher.c9.io' } config.action_mailer.smtp_settings = { :port => 587, :address => "smtp.sendgrid.net", :user_name => "blah", :password => "blah, blah", }

My advice to anyone that comes across this is to avoid SMTP with Cloud9. I’ve spent a couple of days and multiple config attempts trying to make this work. The problem is that it is being blocked somewhere. Mail providers (mailgun, sendgrid) cannot help as they never see the message. Google say that SMTP to one of their providers (mailgun, sendgrid) will be allowed through but it is clearly not.

Luckily I was able to move to the Mailgun api, which is very straightforward, there is a Rails gem and you don’t have to start messing around with ports and SMTP settings. It just works from Cloud9. My advice is to do that. Otherwise you need Cloud9 to look at this issue.

Tom


#5

i am able to send the emails successfully with the following settings:

config.action_mailer.default_url_options = { :host => 'https://abc-*****-1.c9.io' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
    :address              => 'smtp.mailgun.org',
    :port                 => 2525,
    :domain               => 'sandbox************************************.mailgun.org',
    :user_name            => 'postmaster@sandbox******************************.mailgun.org',
    :password             => 'mailgunpassword',
    :authentication => :plain,
    :enable_starttls_auto => true,
    :ssl =>false
}

#6

Hi, I have similar problem sending from C9 through Mandrill. I also have a local machine, from which the email sends fine. On c9 I get the following exception:

Net::OpenTimeout in PasswordResetsController#create
execution expired

and the log

Completed 500 Internal Server Error in 30786ms (ActiveRecord: 12.6ms)

tried to change the hostname in development.rb to config.action_mailer.default_url_options = { :host => 'https://abc-*****-1.c9.io' } but no success…


#7

That host should be the url of your workspace, not literally abc-*****-1.c9.io. What is the mandril URL you are trying to connect to? Are you sure it’s timing out at the send email part and not some other part of your password reset flow?


#8

Hi! I try for a few days to send emails from my workspace using SendGrid app integrate in my Laravel project. I tried a lot of drivers but nothing works till now. I tried to use MailGun app too. It works directly from terminal but not from my Laravel project . In my logs file seems that everything is ok, but mails are not sent. Is there anyone to succeded in doing it? I will appreciate any help. Thank you!
Here are my latest settings:

    .env
        MAIL_DRIVER=sendgrid
        MAIL_ENCRYPTION=tls
        SENDGRID_API_KEY=SG.3x.......Q

config/services:

        'sendgrid' => [
                'api_key' => env('SENDGRID_API_KEY'),
            ],

I even configured default mail services in config/mail

'driver' => env('MAIL_DRIVER', 'sendgrid'),

I tried to use some drivers like this:

https://packagist.org/packages/mabon/laravel-sendgrid-driver

I got the same issue.


#9

Well I succed. It was only my mistake. It works with MailGun API and I am sure it will work with Sendgrid API too. All I had to do was to cache all of your configuration files into a single file using the config:cache Artisan command.


#10

Tom, I am quite new to Rails and Cloud9 and am having the same issues you describe. Would it be possible please to see how you configure your cloud9 side of things to use the mailgun API please?


#12

API Not SMTP is the key factor here that people are missing. If you’re using a plugin make sure it’s configured to use an API (e.g., CURL), instead of SMTP. I used MailGuns and it was pretty easy to do following the instrucitons on their page.