internetee-registry/app/mailers/contact_mailer.rb
Artur Beljajev 1c2407a6e9 Remove legacy test emails
Removes `whitelist_emails_for_staging` setting.

Closes #201
2019-04-07 15:18:27 +03:00

41 lines
1.1 KiB
Ruby

class ContactMailer < ApplicationMailer
include Que::Mailer
helper_method :address_processing
def email_updated(old_email, email, contact_id, should_deliver)
@contact = Contact.find_by(id: contact_id)
@old_email = old_email
unless @contact
Rails.logger.info "Cannot send email in #{self.class.name}##{__method__} with contact_id #{contact_id}. It cannot be found"
return
end
return unless email || @contact
return if delivery_off?(@contact, should_deliver)
begin
mail(to: format(email), subject: "#{I18n.t(:contact_email_update_subject)} [#{@contact.code}]")
rescue EOFError,
IOError,
TimeoutError,
Errno::ECONNRESET,
Errno::ECONNABORTED,
Errno::EPIPE,
Errno::ETIMEDOUT,
Net::SMTPAuthenticationError,
Net::SMTPServerBusy,
Net::SMTPFatalError,
Net::SMTPSyntaxError,
Net::SMTPUnknownError,
OpenSSL::SSL::SSLError => e
logger.info "EMAIL SENDING FAILED: #{email}: #{e}"
end
end
private
def address_processing
Contact.address_processing?
end
end