2015-11-06 88 views
0

试图为RoR4.2应用程序开发环境设置Mailgun,但仍然出现上述错误。正如我从这answer理解配置开发文件有问题。在Devise :: RegistrationsController中使用Cloud9 IDE和Mailgun获取此错误Net :: SMTPSyntaxError#create

这是我的配置/环境/ 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, 
} 

如建议在控制台here我还检查了环境变量,它们的设置是否正确。我建议使用端口2525 herehere。任何想法可能是错误的?

回答

1

所以,我终于得到了答案,无论出于何种原因CLOUD9这里不接受环境变量,所以我不得不硬编码他们只好用“hashrocket”格式:

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  => '[email protected]', 
:password  => 'xxxxxxxxxxxxxxxxxxx', 
:domain   => 'sandboxxxxxxxxxxxxxxxxxx.mailgun.org', 
:enable_starttls_auto => true 
} 

如果有人知道如何在Cloud9 config开发文件中使用环境变量请在这里注释。

0

尝试使用端口587或端口465

CLOUD9是在谷歌的基础设施目前托管的,因此它们的规则适用于工作区CLOUD9过。其中一个限制是关于SMTP。基本上,这是什么意思是:

  • 端口25被阻止
  • 端口587,465,并且可以使用2525
  • 只能使用谷歌Compute Engine的合作伙伴服务,如SendGrid和谷歌Apps的

有关此事的详情,请查看this article

+0

我试过每一个,但不幸的是他们都没有工作。我终于找到了临时解决方案,贴在上面。 – bosp

相关问题