action_mailer_test_via_smtp
If you want to test your e-mails not just in your log, this library is for you. It allows you to configure a test-recipient which gets all mails send via SMTP. Best for testing or staging evironments.
At the moment, this library is only tested with Rails 2.3.8
Usage
Load the gem
config.gem "action_mailer_test_via_smtp"
and in you staging.rb (environment file) you can configure this mode
require "action_mailer_test_via_smtp"
config.action_mailer.delivery_method = :test_via_smtp
config.action_mailer.test_recipient = "[email protected]"
now every single mail will be sent to the test_recipient, prefixed with the original recipient.
Since 0.2.0 you can also test ‘sendmail’ and even ‘test’:
config.action_mailer.delivery_method = :test_via_sendmail
or
config.action_mailer.delivery_method = :test_via_test
I know, the gem name is not valid anymore.
Custom Mail-Header
You can change the standard test mail header by writing your own renderer. Just set
config.test_mail_header_renderer = CustomMailHeaderRenderer
Your class should look something like this
class CustomMailHeaderRenderer < ActionMailerTestViaSmtp::HeaderRenderer::Base
def test_mail_header
# you can access 'mail' which is a TMail::Mail
"return a prepared string"
end
def test_mail_header_html
# you can access 'mail' which is a TMail::Mail
"return a prepared string"
end
end
Note on Patches/Pull Requests
-
Fork the project.
-
Make your feature addition or bug fix.
-
Add tests for it. This is important so I don’t break it in a future version unintentionally.
-
Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
-
Send me a pull request. Bonus points for topic branches.
Copyright
Copyright © 2010 Galaxy Cats IT Consulting GmbH. See LICENSE for details.