1

I am using Rails 3.2.5 and exception_notification gem. In production mode, I am generally sending emails using PostMarkApp's postmark-rails gem.

Initially, I got a View error from exception_notification gem stating

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

so based on exception_notification gem raises ActionView::Template::Error (code converter not found (UTF-8 to UTF-16)) only on Heroku production mode, I moved to

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

This solved that bug. Now, I want the gem to send emails from my gmail account instead of using PostMarkApp credits, so I added the following to my production.rb, yet Exception Notification attempts to send email only from Post Mark App. Why is this setting not working?

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 => "_____" }
Community
  • 1
  • 1
Pykih
  • 2,769
  • 3
  • 29
  • 38

2 Answers2

1

For some reason it appears that SMTP delivery does NOT work in the development environment. I tried a number of different settings and was never able to get this to work. It DOES however work in my other environments. Older posts seem to indicate this as well:

In development, I am using the following in my development.rb:

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

In my "staging" environment, I am using the following in my staging.rb:

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

The staging.rb acquires it's SMTP settings from an initializer I have the uses SendGrid for SMTP:

ActionMailer::Base.smtp_settings = {
  :address              => "smtp.sendgrid.net",
  :port                 => 25,
  :domain               => "test.com",
  :user_name            => "user_name",
  :password             => "password",
  :authentication       => "plain"
}
steakchaser
  • 5,198
  • 1
  • 26
  • 34
0

Try the suggestion at http://www.scottw.com/multiple-smtp-servers-with-action-mailer or at Rails ActionMailer with multiple SMTP servers

Community
  • 1
  • 1
Pratik Khadloya
  • 12,509
  • 11
  • 81
  • 106