From a7a28454a1c541e32fdcc631588150707c434de0 Mon Sep 17 00:00:00 2001 From: riking Date: Fri, 20 Jun 2014 09:31:19 -0700 Subject: [PATCH] DEBUG: Send all email processing errors to admins --- app/jobs/scheduled/poll_mailbox.rb | 6 ++++-- app/mailers/rejection_mailer.rb | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/jobs/scheduled/poll_mailbox.rb b/app/jobs/scheduled/poll_mailbox.rb index dea08f09be5..e0f4c852a87 100644 --- a/app/jobs/scheduled/poll_mailbox.rb +++ b/app/jobs/scheduled/poll_mailbox.rb @@ -27,8 +27,10 @@ module Jobs message = Mail::Message.new(mail_string) client_message = RejectionMailer.send_trust_level(message.from, message.body) Email::Sender.new(client_message, :email_reject_trust_level).send - rescue Email::Receiver::ProcessingError - # all other ProcessingErrors are ok to be dropped + rescue Email::Receiver::ProcessingError => e + # inform admins about the error + data = { limit_once_per: false, message_params: { source: mail, error: e }} + GroupMessage.create(Group[:admins].name, :email_error_notification, data) rescue StandardError => e # inform admins about the error data = { limit_once_per: false, message_params: { source: mail, error: e }} diff --git a/app/mailers/rejection_mailer.rb b/app/mailers/rejection_mailer.rb index 1e060aa55a0..754e51c214c 100644 --- a/app/mailers/rejection_mailer.rb +++ b/app/mailers/rejection_mailer.rb @@ -4,7 +4,7 @@ class RejectionMailer < ActionMailer::Base include Email::BuildEmailHelper def send_rejection(from, body) - build_email(from, template: 'email_reject_notification', from: from, body: body) + build_email(from, template: 'email_error_notification', from: from, body: body) end def send_trust_level(from, body, to)