exception_notification:smtp无法正常工作

时间:2012-12-28 12:00:41

标签: smtp ruby-on-rails-3.2 postmark exception-notification

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

最初,我从exception_notification gem stating

获得了一个View错误
ActionView::Template::Error (code converter not found (UTF-8 to UTF-16))

所以基于exception_notification gem raises ActionView::Template::Error (code converter not found (UTF-8 to UTF-16)) only on Heroku production mode,我搬到了

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

这解决了这个bug。现在,我希望gem从我的Gmail帐户发送电子邮件而不是使用PostMarkApp信用,因此我将以下内容添加到我的production.rb,但Exception Notification尝试仅从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 => "_____" }

2 个答案:

答案 0 :(得分:1)

出于某种原因,似乎SMTP传递在开发环境中不起作用。我尝试了许多不同的设置,但从来没有能够让它工作。然而,它可以在我的其他环境中工作。较旧的帖子似乎也表明了这一点:

在开发中,我在开发中使用以下内容.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从我使用SendGrid for SMTP的初始化程序获取它的SMTP设置:

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.sendgrid.net",
  :port                 => 25,
  :domain               => "test.com",
  :user_name            => "user_name",
  :password             => "password",
  :authentication       => "plain"
}

答案 1 :(得分:0)