Mailtrap: Dummy Ruby SMTP server (ideal for testing ActionMailer)
Mailtrap is a "dummy" SMTP server developed in Ruby by Matt Mower. The main use for Mailtrap is to act as an SMTP server that runs locally and can be sent mail which can be inspected for debugging purposes. For example, your Rails application running locally might need to send mail using ActionMailer, and while you want it to go through all of the SMTP motions, you don't want the mail to really be sent.. enter Mailtrap! In this blog post, Matt goes into more details about how Mailtrap works, why it's a good idea, and the motivation behind its development.
October 18, 2007 at 8:45 am
I love those KISS projects. Going to digg into the code if I've got some spare time today!
October 19, 2007 at 8:35 am
Why would you even distribute a picture like this?
Surely you can be more creative to represent the word `Trap`.
Animal cruelty is not something to condone!
Terrible, this alone will deter me from Mailtrap or even give a glance.
October 21, 2007 at 4:09 pm
It looks like hyper-sensitivity is not just an American thing.
October 21, 2007 at 4:28 pm
Is this for testing ActionMailer or for testing apps that use ActionMailer? Because it certainly seems great for the former purpose. But I can't see a need if you're testing your app. Basically, you just need to test whether you're calling ActionMailer stuff correctly - you don't need to test ActionMailer itself (unless you're workiing on ActionMailer).
///ark
October 22, 2007 at 7:55 am
Mark Wilden: When I'm running in development mode on my laptop I don't want to have to bother configuring an actual SMTP server or bother about the emails and where they end up (e.g. coming in to my mailbox and having to delete them).
During testing I establish (with the :test mailer) that the emails are correctly generated. When I'm doing local development I just want ActionMailer to think they have been sent okay. That's what Mailtrap is for.
Mailtrap allows me to use the SMTP configuration for ActionMailer that I am already familiar with from production. I just configure it for localhost port 2525 and start Mailtrap.
Now I can run in development mode and mails will be sent out as normal and will just collect in a log file.
If you've already got a local SMTP server (e.g. postfix) configured and are happy filtering or manually deleting the emails then more power to you.
For someone too lazy to do that (i.e. Me)... there's Mailtrap.
Regards,
Matt
October 22, 2007 at 4:18 pm
Thanks for the explanation, Matt. From AWDw/R (p. 567), I thought people could use :test in development, too. But when you're developing with :smtp, then I can see that Mailtrap would be very useful, indeed.
///ark
October 31, 2007 at 8:10 am
this is cool. been using action_mailer_tls and sending everything thru gmail but this'll work