Triggering actions by email

Sometimes you need to trigger events by sending email. For example lets say you want to create an email address that will accept messages and show them on some type of LED display. There are a number of ways to do this, but the simplest is to set the .forward file for the email account to pipe the contents of every message it gets into a program. The program can parse the message and do whatever else you want it to do.

The .forward file will normally let you forward every incoming message to another email address. So if you go to your home directory and create a .forward file like this:

[email protected]

All of your emails will now be forwarded to Bob. If you want to forward your emails to Bob and keep a copy for yourself as well you can do this:

\myName, [email protected]

The slash tells the system to only deliver the message once. Otherwise it will receive the message, deliver the message, notice the delivered message and deliver it again and again.

To pipe the message into a program you can do this:


When I was testing this I wanted to make TextEdit on OS X open up with every new message I received. The command open -f instructs OS X to open TextEdit with whatever text is piped into it. So I changed my .forward file to:

"| open -f"

and every time I received an email on my local machine it automatically opened in TextEdit.

By creating programs that can parse the email message you can do things much more interesting.


Leave a Reply

Your email address will not be published. Required fields are marked *