Using Cloud9 IDE and Mailgun getting this error Ne

2019-09-01 00:23发布

问题:

Trying to set up Mailgun for RoR4.2 app development environment but still getting the above error. As I understood from this answer there is problem with config development file.

This is my config/environments/development.rb:

 config.action_mailer.raise_delivery_errors = true
 config.action_mailer.perform_deliveries = true

 host = 'my_app.c9.io'
 config.action_mailer.default_url_options = { host: host }

 config.action_mailer.delivery_method = :smtp
 config.action_mailer.smtp_settings = {
 address: 'smtp.mailgun.org',
 port: '2525',
 domain:     ENV["MAILGUN_DOMAIN"],
 user_name:  ENV["MAILGUN_USERNAME"],
 password:   ENV["MAILGUN_PASSWORD"],
 authentication: :plain,
 enable_starttls_auto: true,
 }

As suggested here I also checked environment variables in console, they are properly set. I'm using port 2525 as suggested here and here. Any ideas what can be wrong?

回答1:

So I finally get the answer, for whatever reason Cloud9 don't accept environment variables here so I had to hardcode them and had to use "hashrocket" format:

config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true

host = 'my_app.c9.io'
config.action_mailer.default_url_options = { host: host }

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address        => 'smtp.mailgun.org',
:port           => '2525',
:authentication => :plain,
:user_name      => 'postmaster@xxxxxxxxxxxxxxxxx.mailgun.org',
:password       => 'xxxxxxxxxxxxxxxxxxx',
:domain         => 'sandboxxxxxxxxxxxxxxxxxx.mailgun.org',
:enable_starttls_auto => true  
}

If anybody knows how to use environment variables in Cloud9 config development file please comment here.



回答2:

Try using port 587 or port 465.

Cloud9 is currently hosted on Google's infrastructure, and therefore their rules apply to Cloud9 workspaces too. One of their restrictions is regarding SMTP. Basically what this means is:

  • Port 25 is blocked
  • Ports 587, 465, and 2525 can be used
  • Can only use Google Compute Engine partner services, like SendGrid and Google Apps

For details on the matter, please check out this article.