本文介绍了使用Cloud9 IDE和Mailgun在Devise :: RegistrationsController#create中获得此错误Net :: SMTPSyntaxError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试为RoR4.2应用程序开发环境设置Mailgun,但仍出现上述错误.据我从 answer 了解到存在问题配置开发文件.

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.

这是我的config/environments/development.rb:

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,
 }

根据建议的此处,我还在控制台中检查了环境变量,它们的设置正确.我按照建议的此处使用端口2525,并此处.有什么想法可能是错误的吗?

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?

推荐答案

因此,无论出于何种原因,Cloud9都不接受此处的环境变量,因此我终于得到了答案,因此我不得不对其进行硬编码并必须使用"hashrocket"格式:

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

如果有人知道如何在Cloud9 config开发文件中使用环境变量,请在此处评论.

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

这篇关于使用Cloud9 IDE和Mailgun在Devise :: RegistrationsController#create中获得此错误Net :: SMTPSyntaxError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 06:47