Malm. Super simple mail server for development

Update March 2017 - use mailcatcher instead

This was a cool thing to play around with, but never got fully fleshed out. The excellent mailcatcher by fellow Melbourne local Sam Cochran does a much better job.

TL;DR

Malm is a super simple SMTP server/reader. It catches any message sent to it for any email address on any domain. But doesn’t forward anything on, and gives you a web view to look at what it’s caught. Point your local app’s SMTP config at it, and you’ll have a nicer time working with email sending code at development time.

gem install malm
malm # malm starts with SMTP running on port 2525, and web mail client on port 4567

Then set up your app to send SMTP messages to localhost on port 2525

Any email messages that your app sends out can then be viewed on http://localhost:4567

Coding email logic sucks

Email is a hassle. The code itself is fine, but the environment and tools around it are just extra friction that makes it harder to get things done.

Say I’ve just coded the sign in process for http://adopt-a-shaved-yak.example.com. I’m running locally on my dev box. It asks me to register. All the usual details. So I type in madlep@example.local for the email.

And then the app sends me a confirmation message.

Crap. I need to click on the link to activate the account, and I hadn’t set up a mail server running at example.local. The message went to a black hole. Lets spend 10 minutes getting a temp mail server running… And set up a host name pointing at example.local… And add a throw away account on the mail server… And then set up a login to that account on your mail client… Half an hour gone. I need another coffee.

Ok. Back from my coffee break. Where was I? Right, we’ll do the sign up again. Oh, now the app validation says I can’t use the same email address. Hmmm, let’s do the account setup routine again with a different username… 10 minutes later… Done. Now we can test the confirmation link. Awesome.

What’s next? What? Now I need to do something with accounts on different domains? You mean I’ll need to tweak host files so mail gets delivered to my test mail server?… GAH

By now it’s lunch time. I’m well caffeinated, but I haven’t gotten much done.

Malm is a better way

I don’t want to mess around with mail servers, and I get bored of mashing refresh in my mail client to look at what my app is sending out.

So this is where Malm comes in. It’s a simple gem I threw together to solve this problem. Just install the gem, start it up, and you’ve got a basic SMTP server your app can use. Plus it doubles as a web based email message viewer so you can easily view what your app has spammed to the world.

Malm uses GServer for talking SMTP, and Sinatra for the web front end. It’s all self contained with minimal dependencies and no configuration required.

You can even start it as a background daemon process if you want.

The web front end is still a bit rough, but is functional, and lets you see plaintext and HTML content for messages received.

It’s super useful combined with a Vagrant VM running the rest of your development environment. That’s how I’m using it.

And if it lets me avoid Outlook and/or Exchange… I’m happy.

Malming it up

Go get it {% highlight bash %} gem install malm {% endhighlight %}

And run it {% highlight bash %} malm # malm starts with SMTP running on port 2525, and web mail client on port 4567 {% endhighlight %}

Or as a background daemon process {% highlight bash %} sudo -E malm -p 25 –start # starts on regular SMTP port 25, and as a background process sudo -E malm –stop # stop it again later {% endhighlight %}

Getting help {% highlight bash %} malm –help # what it says {% endhighlight %}

Source code is on github for anyone interested.

What’s a Malm?

A bedroom drawer range from Ikea. It’s easy to setup, then you just chuck all your stuff at it, and it keeps it for you to do something with later. Kind of like Malm, the super simple mail server.

I was going to call this “mail me” or something like that, but thought that name might lead to confusion. So I just splatted the words together and said it fast, and I got “Malm”. I’d just assembled a couple of these babies for the room upstairs, so it was fresh in my mind and it stuck.