DailyJS

Receiving Emails with Node

Alex R. Young

Subscribe

@dailyjs

Facebook

Google+

node email modules npm servers

Receiving Emails with Node

Posted by Alex R. Young on .
Featured

node email modules npm servers

Receiving Emails with Node

Posted by Alex R. Young on .

One of the things I like to evangelise about Node is the fact it's good for creating any network servers, not just web stuff. Florent Galland sent in Mailin (GitHub: Flolagale / mailin, License: MIT, npm: mailin), which allows your web apps to receive inbound emails. What's cool about Mailin is it runs as an SMTP server, so rather than having to configure a mail server you can just use Mailin by itself.

Mailin's homepage has a cool demo that allows you to send it an email and see it appear on the page. This works using Mailin's webhook.

Mailin

You can configure the webhook when the server is started:

mailin --webhook http://example.com/incoming_emails  

The documentation explains how to install it with authbind for safe binding to port 25, otherwise sudo or a root user would be required.

The documentation also mentions optional spam detection support.

Mailin is built with the simplesmtp module. This provides a Node API for building SMTP servers. It has an API that should be familiar to anyone who has written HTTP code with Node:

simplesmtp.createSimpleServer({ SMTPBanner: 'My Server' }, function(req) {  
  req.pipe(process.stdout);
  req.accept();
}).listen(port);

simplesmtp even supports connection pools, and TLS. I love the idea of using Node for servers that I can customise, but I'm not a security expert so I don't know what the implications of using these modules in production might be. Maybe it's time I read Node Security!