Skip to content

Instantly share code, notes, and snippets.

@ritikesh
Created August 25, 2020 08:58
Show Gist options
  • Save ritikesh/5444ecfe4ff94aa540d05daa693cab0b to your computer and use it in GitHub Desktop.
Save ritikesh/5444ecfe4ff94aa540d05daa693cab0b to your computer and use it in GitHub Desktop.
blog gists
module MailObserver
def self.delivered_email(mail)
logger = ActionMailer::Base.logger
logger.tagged(mail.message_id) do
logger.info do
recipients = Array(mail.to).join(', ')
"Sent mail to #{recipients}"
end
end
logger.debug { mail.encoded }
end
end
ActionMailer::Base.register_observer(MailObserver)
module MailLogSubscriber
def deliver(event)
# no-op
end
end
ActionMailer::LogSubscriber.prepend(MailLogSubscriber)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment