Skip to content

galaxycats/action_mailer_test_mailing

Repository files navigation

action_mailer_test_mailing

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 environments.

At the moment, this library is only tested with Rails 2.3.8

Usage

Load the gem

config.gem "action_mailer_test_mailing"

and in you staging.rb (environment file) you can configure this mode

require "action_mailer_test_mailing"
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 < ActionMailerTestMailing::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 © 2010 Galaxy Cats IT Consulting GmbH. See LICENSE for details.

About

Test E-Mails of ActionMailer via smtp or sendmail in testing/staging environments

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages