1

Rails 3.2.5 と exception_notification gem を使用しています。本番モードでは、通常、PostMarkApp の postmark-rails gem を使用してメールを送信しています。

最初に、exception_notification gem から 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'

これでそのバグは解決しました。ここで、PostMarkApp クレジットを使用する代わりに、gmail アカウントからメールを送信するように gem を設定したいので、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 => "_____" }
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 に答える