Email Debugging with MailCatcher

Posted by Unknown on Thursday, May 22, 2014

You use email in your applications, right? Ok, that’s a rhetorical question. Of course you do. Despite email being over 30 years old, it’s still the most popular application on the planet, by far. Here are some stats from Pingdom, for 2012:



  • 2.2 billion – Number of email users worldwide

  • 144 billion – Total email traffic per day worldwide

  • 4.3 billion – Number of email clients worldwide in 2012


Staggering!


But why another article on email?


For one simple reason, one which we’ve likely all been caught by at one point or another. Because we need to test, as close to production as we can, but without emailing our clients accidentally, and them consequently becoming confused or frustrated, or embarrassed that their clients have received test emails.


I’m sure you know what I mean. You think you’ve set your application in some kind of debug mode. Given that, you start your test, which sends a load of emails from your application. All the while, you feel comfortable in the knowledge that no one but you is ever going to see them.


Your tests pass, you congratulate yourself, and move on. A short time later, you receive a rather, let’s just say terse, Skype call from your client. She’s rather annoyed as her customers have been ringing up, asking why they’ve been receiving odd emails from her company. She’s not happy and wants answers?


Been there? Don’t want to be there again? I’m guessing you don’t. Here’s the solution - MailCatcher. If you’re not familiar with it, MailCatcher



…runs a super simple SMTP server which catches any message sent to it to display in a web interface. Run mailcatcher, set your favourite app to deliver to smtp://127.0.0.1:1025 instead of your default SMTP server, then check out http://127.0.0.1:1080 to see the mail that’s arrived so far.



Sound like a good solution? No matter if you’re tired, under pressure, new on the team, or just need to run tests - MailCatcher will ensure that no email ever gets sent outside of your network, or even outside of your development virtual machine.


In this post, I’m going to show you how to set it up and run through the interface when emails have been captured by it.


A Pre-Prepared Virtual Machine


To save you a lot of trouble of getting MailCatcher set up, I’ve created a custom Vagrant box which does it all for you. Make sure you have VirtualBox and Vagrant installed, then clone a copy of the article’s repository using the following command:



git clone git@github.com:sitepoint/mailcatcher-article.git

Continue reading %Email Debugging with MailCatcher%




more

{ 0 comments... » Email Debugging with MailCatcher read them below or add one }

Post a Comment

Popular Posts