Created
January 24, 2011 12:46
-
-
Save pablobm/793168 to your computer and use it in GitHub Desktop.
Print email to stdout and log/mail.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/development_email_interceptor.rb | |
class DevelopmentMailInterceptor | |
def self.delivering_email(message) | |
File.open(File.join(Rails.root, *%w{log mail.log}), 'a') do |output| | |
output << "___ EMAIL STARTS ______________________________\n" | |
output << message.encoded | |
output << "^^^ EMAIL ENDS ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n" | |
end | |
puts "Send email to #{message.to}. Subject: #{message.subject}" | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/email.rb | |
if Rails.env.development? | |
require 'development_mail_interceptor' | |
ActionMailer::Base.register_interceptor(DevelopmentMailInterceptor) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment