1

我正在使用 Rails 3.2.5 和 exception_notification gem。在生产模式下,我通常使用 PostMarkApp 的 postmark-rails gem 发送电子邮件。

最初,我从 exception_notification gem 中得到一个查看错误,说明

ActionView::Template::Error (code converter not found (UTF-8 to UTF-16))

所以基于exception_notification gem 仅在 Heroku 生产模式下引发 ActionView::Template::Error (code converter not found (UTF-8 to UTF-16)),我搬到

gem 'exception_notification', git: 'git://github.com/alanjds/exception_notification.git'

这解决了那个错误。现在,我希望 gem 从我的 gmail 帐户发送电子邮件,而不是使用 PostMarkApp 积分,因此我将以下内容添加到我的 production.rb 中,但异常通知尝试仅从 Post Mark App 发送电子邮件。为什么这个设置不起作用?

config.middleware.use ExceptionNotifier,
    sender_address: 'noreply@mydomain.com',
    exception_recipients: 'myemail@mydomain.com',
    sections: %w{current_user} + ExceptionNotifier::Notifier.default_sections,
    ignore_crawlers: %w{Googlebot bingbot},
    email_format: true,
    normalize_subject: true,
    smtp_settings: {
        :address              => "smtp.gmail.com",
        :port                 => "587",
        :domain               => "www.gmail.com",
        :user_name            => "myemail@gmail.com",
        :password             => "mypassword",
        :authentication       => "plain",
        :enable_starttls_auto => true,
        :openssl_verify_mode  => 'none'        
      }

config.action_mailer.delivery_method   = :postmark
config.action_mailer.postmark_settings = { :api_key => "_____" }
4

2 回答 2

1

由于某种原因,似乎 SMTP 传递在开发环境中不起作用。我尝试了许多不同的设置,但始终无法使其正常工作。但是,它确实可以在我的其他环境中使用。较早的帖子似乎也表明了这一点:

在开发中,我在 development.rb 中使用以下内容:

config.action_mailer.delivery_method = :letter_opener
config.middleware.use ExceptionNotifier,
  :sender_address => 'test@test.com',
  :exception_recipients => 'recipient@test.com'

在我的“暂存”环境中,我在 staging.rb 中使用以下内容:

config.action_mailer.delivery_method = :smtp
config.middleware.use ExceptionNotifier,
  :sender_address => 'test@test.com',
  :exception_recipients => 'recipient@test.com'

staging.rb 从初始化程序获取它的 SMTP 设置,我使用 SendGrid 进行 SMTP:

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.sendgrid.net",
  :port                 => 25,
  :domain               => "test.com",
  :user_name            => "user_name",
  :password             => "password",
  :authentication       => "plain"
}
于 2013-04-16T00:18:05.290 回答
0

在http://www.scottw.com/multiple-smtp-servers-with-action-mailer 或在具有多个 SMTP 服务器的 Rails ActionMailer尝试建议

于 2012-12-28T17:54:14.400 回答