【问题标题】:Using Cloud9 IDE and Mailgun getting this error Net::SMTPSyntaxError in Devise::RegistrationsController#create使用 Cloud9 IDE 和 Mailgun 在 Devise::RegistrationsController#create 中收到此错误 Net::SMTPSyntaxError
【发布时间】:2015-11-06 11:17:31
【问题描述】:

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

这是我的配置/环境/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 建议的那样,我还在控制台中检查了环境变量,它们已正确设置。我按照here 和here 的建议使用端口2525。有什么想法有什么问题吗?

【问题讨论】:

    标签: ruby-on-rails-4 cloud9-ide mailgun


    【解决方案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      => 'postmaster@xxxxxxxxxxxxxxxxx.mailgun.org',
    :password       => 'xxxxxxxxxxxxxxxxxxx',
    :domain         => 'sandboxxxxxxxxxxxxxxxxxx.mailgun.org',
    :enable_starttls_auto => true  
    }
    

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

    【讨论】:

      【解决方案2】:

      尝试使用端口 587 或端口 465。

      Cloud9 目前托管在 Google 的基础架构上,因此它们的规则也适用于 Cloud9 工作区。他们的限制之一是关于 SMTP。基本上这意味着:

      • 25 端口被阻塞
      • 可以使用端口 587、465 和 2525
      • 只能使用 Google Compute Engine 合作伙伴服务,例如 SendGrid 和 Google Apps

      详情请关注this article。

      【讨论】:

      • 我尝试了每一个,但不幸的是它们都不起作用。我终于找到了临时解决方案,贴在上面。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-24
      • 1970-01-01
      • 2015-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-24
      相关资源
      最近更新 更多