首页 文章

使用Mandrill在 生产环境 中发送Devise电子邮件

提问于
浏览
0

我正在尝试从我的Rails 4应用程序发送Devise电子邮件 . 我不想更改模板或任何东西,我只想使用Mandrill在 生产环境 环境中传递消息 .

我的 production.rb 是这样的:

config.action_mailer.raise_delivery_errors = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.default_url_options = {:host => 'sociedadeavalia.com.br'}
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
    :address => "smtp.mandrilapp.com",
    :port    => 587,
    :user_name => ENV['MANDRILL_USERNAME'],
    :password => ENV['MANDRILL_APIKEY'],
    :authentication => 'login',
    :enable_starttls_auto => true,
    :domain  => 'sociedadeavalia.com.br'
  }

我在 devise.rb 中有这个

config.mailer_sender = 'no-reply@sociedadeavalia.com.br'
config.mailer = 'MyDeviseMailer'

我创建了以下邮件:

class MyDeviseMailer < Devise::Mailer
  helper :application
  include Devise::Controllers::UrlHelpers
  default template_path: 'devise/mailer'  
end

现在,每当我尝试在 生产环境 中发送电子邮件(用于创建新用户帐户的确认电子邮件)时,我的应用程序就会崩溃并显示在日志中:

31 <190>1 2014-12-03T22:17:07.987969+00:00 app web.1 - - Net::OpenTimeout (execution expired):

在这种情况下我该怎么办?

2 回答

  • 1

    看起来您可能遇到阻塞端口的问题 . 我们建议您执行故障排除步骤here . 更具体地说,尝试更改您正在使用的端口 - 通常不会阻止2525,或者在启用SSL时使用465 . 许多主机阻止25和587以帮助防止垃圾邮件 .

  • 0

    尝试将身份验证更改为“plain” . 这对我有用 .

    :authentication => 'plain',
    

相关问题