hummingbird-me/kitsu-server

View on GitHub
app/mailers/application_mailer.rb

Summary

Maintainability
A
0 mins
Test Coverage
B
80%
class ApplicationMailer < ActionMailer::Base
  SMTP_SOFT_BOUNCES = [
    Errno::EINVAL,
    Errno::ECONNRESET,
    Errno::ECONNREFUSED,
    EOFError,
    Net::ProtocolError,
    SocketError,
    IOError,
    Timeout::Error,
    Postmark::HttpClientError,
    Postmark::InternalServerError,
    Postmark::TimeoutError
  ].freeze
  SMTP_HARD_BOUNCES = [
    Postmark::InactiveRecipientError,
    Net::SMTPFatalError,
    Net::SMTPSyntaxError
  ].freeze

  include Rails.application.routes.url_helpers
  default from: 'Kitsu <help@kitsu.app>'
  layout 'mailer'

  rescue_from(*SMTP_HARD_BOUNCES) do
    raise MailSendError::HardBounce
  end

  rescue_from(*SMTP_SOFT_BOUNCES) do
    raise MailSendError::SoftBounce
  end
end