Skip to content


MailFactory – A rails plugin for testing email

I made a rails plugin called MailFactory, it generates an email object that you can use to test your email receiving in a rails app. Here’s how you use it:

Install:
script/plugin install git://github.com/thinkbohemian/MailFactory.git

Use:
mail = mail_factory(:from_email => from_email , :to_email => to_email , :subject => subject, :body => body)

Example:

If you want to simulate receiving an email from “foobar@example.com”,
sent to “you@example.com” with a subject of “my cool subject” and a
body of “this is only a test” you could create the object like this:

mail = mail_factory(:from_email => "foobar@example.com" ,<br /> :to_email => "you@example.com" , :subject => "my cool subject",<br /> :body => "this is only a test")

You can then use in your application as if rails had received an email:
TMail::Mail.parse(mail).from.to_s
=> “foobar@example.com”

Posted in Uncategorized.

0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.