Answer the question
In order to leave comments, you need to log in
How to read smtp ActionMailer settings in error_handler?
Here are the default smtp settings for the ActionMailer::Base class mail method
config/application.rb
module MyApp
class Application < Rails::Application
...
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
enable_starttls_auto: true,
address: 'smtp.yandex.ru',
port: 587,
....
user_name: xxxx
password: yyy
}
end
class SomeMailer < ActionMailer::Base
include Resque::Mailer
...
def send_feedback opts
...
mail(to: to, subject: 'subj',
delivery_method_options: get_random_smtp_settings)
end
end
Resque::Mailer.error_handler = lambda { |mailer, message, error, action, args|
if error.is_a?(Resque::TermException)
Resque.enqueue(mailer, action, *args)
else
SMS.send_error :admin, {error: error.message, error_class: error.class, smtp_login: ????, smtp_pass: ????}
raise error
end
mailer.smtp_settings[:user_name]
mailer.smtp_settings[:password]
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question