Slack hack: local mail delivery

Jakub Roztocil
HackerNoon.com
2 min readDec 3, 2016

--

Then one / Wired

It’s not a secret that Slack is great for team communication. But what makes it shine is the ability to connect anything to your team’s channels.

“Botifying” a server

If you run any servers at all, chances are they occasionally send you system notifications. Because these are sent using the local mail delivery system, it’s likely you never get to read them or only when it’s too late; all local mail by default ends up in/var/spool/mail/root. You will need to SSH to the server to learn about them from a cute You have new mail notification in the terminal.

The common solution is to enable forwarding to an external email address. This solution is unreliable, however, because messages get often marked as spam or rejected by the receiving server—unless you take extra care to make your host look like a legit mail server to the outer world.

Another issue is that Unix servers don’t come with a Share in Slack feature for some reason.

Let’s quickly fix both:

  1. Add a new email integration to your Slack team and copy the email address:

2. Install a mail transport agent on your server, for example:

3. Enable forwarding of all root mail to Slack:

Done!

You’ve just established a direct email line from your server to Slack. Let’s test it out:

Or something a little bit more useful:

…just kidding, don’t do that. But you get the idea.

As you can see, you can now send messages from your server to Slack simply by mailing to root.

By the way, this is what system services—such as cron, logwatch, and others—already use for notifications about important events and problems. So you’ll get those automatically to Slack as well:

Mail from logwatch delivered to Slack

--

--

Jakub Roztocil
HackerNoon.com

Software engineer obsessed with simplicity and the human experience of code, design, and information. Captivated by the power APIs. Building @httpie & hiring!