Raspberry Pi, Send Me a Letter

The abundance of small networked boards running Linux — like the Raspberry Pi — is a boon for developers. It is easy enough to put a small cheap computer on the network. The fact that Linux has a lot of software is a double-edged sword. On the one hand, it is a good bet that anything you want to do has been done. On the other hand, some of the solutions are a bit large for a tiny embedded system.

Take, for example, e-mail. Historically, Linux hosts operate as mail transfer agents that can send and receive mail for all their users and possibly even relay mail to others. In today’s world, that’s usually overkill, but the capability is there. It is possible to install big mail transfer agents into a Raspberry Pi. The question is: should you?

What Do You Want?

The answer, of course, depends on what you want to do. If you have a dedicated board sending out text and maybe even files using an external mail server (like, say, Gmail), then the answer is no. You don’t need a piece of software listening for incoming connections, sorting through multiple users, and so on.

Luckily, there are some simple solutions if you know how to set up and configure them. The key is to avoid the big mail programs that do everything you don’t need.

Mail Front Ends

Let’s tackle sending mail first. If you try to grab the mailutils package, you’ll see it drags along a lot of stuff including mysql. Keep in mind, none of this will actually send mail. It just gives you some tools to get mail ready to send.

Luckily, the bsd-mailx package has a lot less overhead and will do the job. Look at the man page to see what options you have with mailx; you can do things like attach files, set a subject, and specify addresses.

It is a little difficult to set up for Gmail, though, thanks to Google’s security. You’ll need the certutil tool from the libnss3-tools package. You’ll need to create a certificate store, import Google’s certificate, and then set up a lot of options to mailx. I don’t suggest it. If you insist, though, you can find directions on the Web.


By default, programs like mailx and other Linux mail commands rely on a backend (often sendmail). Not only does that drag around too much overhead, it is also a full mail system, sending and receiving and relaying–overkill for our little Pi computers.

Luckily, SSMTP is available which only sends mail and is relatively lightweight. You need a configuration file to point it to your mail server. For Gmail, it would look like this:

# Config file for sSMTP sendmail
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.

# The place where the mail goes. The actual machine name is required no 
# MX records are consulted. Commonly mailhosts are named mail.domain.com

# Where will the mail seem to come from?

# The full hostname
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address

You can use a mail agent like mailx or you can just use ssmtp directly:

ssmtp someone@somewhere.com

Enter a message on the standard input and end it with a Control+D (standard end of file for Linux).

Google Authentication

There’s only one catch. If you are using Gmail, you’ll find that Google wants you to use stronger authentication. If you are using two-factor (that is, Google Authenticator), this isn’t going to work at all. You’ll need to generate an app password. Even if you aren’t, you will probably need to relax Google’s fear of spammers on your account. You need to turn on the “Access for less secure apps” setting. If you don’t want to do this on your primary e-mail account, considering making an account that you only use for sending data from the Pi.

Sending Files

Depending on the mail software you use, there are a few ways you can attach a file. However, the mpack program makes it very easy:

mpack -a -s 'Data File' datafile.csv me@hackaday.com

The above command will send datafile.csv as an attachment with the subject “Data File.” Pretty simple.

Receiving Mail

What if you want to reverse the process and receive mail on the Pi? There is a program called fetchmail that can grab e-mails from an IMAP or POP3 server. It is possible to make it only read the first unread message and send it to a script or program of your choosing.

You have to build a configuration file (or use the fetchmailconf program to build it). For example, here’s a simple .fetchmailrc file:

poll imap.gmail.com
protocol IMAP
user "user@gmail.com" with password "yourpassword" mda "/home/pi/mailscript.sh"
folder 'INBOX'
fetchlimit 1

You can leave the “keep” line out if you don’t mind fetchmail deleting the mail after processing. The file should be in your home directory (unless you specify with the -f option) and it needs to not be readable and writable by other users (e.g., chmod 600 .fetchmailrc). According to the fetchmail FAQ, there are some issues with Gmail, so you might want to consider some of the suggestions provided. However, for simple tasks like this, you should be able to work it all out.

In particular, the mailscript.sh file is where you can process the e-mail. You might, for example, look for certain keyword commands and take some action (perhaps replying using ssmtp).

Special Delivery

You might not think of the Raspberry Pi as an e-mail machine. However, the fact that it is a pretty vanilla Linux setup means you can use all sorts of interesting tools meant for bigger computers. You just have to know they exist.

Gmail One Step Closer to Human Enslavement

Apply some lessons learned in Sci-Fi literature and you’ll come to the same realization I have: Google is going to unknowingly enslave humanity to an artificial intelligence.

I read a lot of science fiction. Generally, the future of technology can be found in great novels if you read between the lines. One of my favorites in this regard is, of course, [Neal Stephenson] who writes cripplingly long books that are totally worth the read due to his brand of fact-backed forward thinking. Look back on my posts here at Hackaday and you’ll see that I frequently apply concepts from his book The Diamond Age to what we see in emerging technology.

Last year my friend [Nils] suggested I give [William Hertling] a try, specifically his Singularity Series which starts with the novel Avogadro Corp. The fictional company is the world leader in free email and data storage. Sound like someone we know? One of the research projects within the company is an email plugin called ELOPe that will parse all past communications and choose topics and phrases that have the highest probability of eliciting a positive response from the recipient. When funding for the project is threatened, the system is turned on. I’d like to avoid spoilers, but let’s just say this puts the system on a path toward enslaving society.

Google is now boasting “Machine Intelligence for You”. It’s a research project based around Gmail which is called Inbox. Inbox has been around for a while but the newly announced feature is an algorithm that reads the email for you and suggests a set of responses. Compared to Avogadro Corp this is only missing two things: the ability to respond automatically, and the directive to protect itself at all costs.

One of the things I liked best about [William Hertling’s] take on an Artificial Intelligence was the low-key nature of the entity. It wasn’t a super-high-level thinker that interacts just like a human would. It was a poor choice by one programmer that led to horrible and far-reaching unintended consequences. No, I don’t really think Google’s Inbox will enslave us. But I appreciate the irony of life imitating art.

[via PopSci]

First Responder Call-In Using Google Voice


Firefighters and firehouses are not as glamorous as your kindergarten self would lead you to believe. Most firefighters in the US are volunteers, and most firefighters don’t live in the firehouse. Instead of hanging out at the fire house all the time, they use a call-in system that displays a list on a web page saying, ‘Joe is coming to the fire house’ or ‘Jack will meet you at the scene’. It’s highly efficient given the budgets they’re working with, but as [Andy] discovered, this same system can be replicated with Google Voice.

The system relies on a Google Voice account that’s set to have all calls go straight to voicemail. The missed call sends off a voicemail notification to the Gmail inbox, effectively turning the Gmail inbox into a call-in system for free.

In testing, [Andy] noticed the Gmail inbox doesn’t quite refresh fast enough for his purposes, so he whipped up a simple webpage with a little bit of PHP to parse the emails and display everything automatically. The idea being that this webpage could just be displayed on a monitor in the station, waiting for the next call.

Another improvement [Andy] points out could be setting up several numbers, each for different status codes. It’s an astonishing simple system, and now something that can be replicated for free.

Web connectivity and other addons for an automatic schnauzer feeder


[Ben Miller] and his dad combined forces to create this automatic dog feeder. It not only keeps their two schnauzers happy, but gives them peace of mind as they can double-check that he feeding happened by pulling up an image on the Internet. Make sure you make it through all three posts of the build to get the entire picture.

The project started with some research which turned up a project that used a commercially available automatic feeder. That one used Arduino, but because of the cost the board plus a WiFi shield is a bit high, [Ben] went with a Raspberry Pi and a USB WiFi dongle instead. The Pi is much more powerful and adds the functionality for capturing images via a webcam.

After a convoluted process of connecting the Pi to the existing button traces on the automatic feeder it was time to start coding. The system runs from a Perl script which monitors a Gmail account for remote commands (in addition to a regular feeding schedule). The final touch is a bit of mechanical engineering which splits the output into two bowls so the dogs each have their own serving.

We still use the Autodine we built several years back but its single-serving limitation has always kept a second version on our project list. Hopefully seeing a well-executed system like this will motivate us to get building!

Wireless unread email counter tells you how busy you’re not


One of the marks of how busy you are – or how well your spam filters are set up – is how many unread emails you have in your inbox. [trumpkin] over on Instructables posted a great tutorial for making a wireless counter that displays the number of unread emails in your Gmail account.

[trumpkin] used a tiny and inexpensive 419 MHz transmitter and receiver combo to make this project work. On his desktop, he wired up a USB to UART bridge attached to the transmitter. For the receiver side, an ATMega328 reads the data coming off the receiver and displays the number of unread emails on two seven-segment displays.

The wireless device runs off of two AA batteries and should provide enough power to keep the email monitor running for a long time. More than enough time for your inbox to fill up and for you to become overwhelmed with the work you should be doing.

Rudolph toy hacked to announce incoming email


Tis the season for hacking, and [Nick McClanahan] at the GadgetGangster is certainly showing off his Christmas spirit with his most recent creation. He had an animatronic Rudolph the Red Nosed Reindeer toy sitting around and thought it would be fun to convert him into an email reading machine.

He tore open the toy, removing its innards, disconnecting the built-in speaker and servos from the original PCB. He then extended wires from those components outside of the body before reassembling the toy. The reindeer is controlled primarily using a Propeller Platform, with an E-Net module and a small audio amp taking care of network communications and audio output, respectively.

Most of the work is done by the software [Nick] is using, which allows Rudolph to periodically check his Gmail inbox for new messages. When the message count increases, the reindeer springs into action, moving and lighting up his nose before announcing the sender’s name.

He’s using a phonemic voice synthesizer for the output, which does the job, though we would go mad if we had to listen to it all day. Since the reindeer is connected to his LAN, it might be feasible to run the data through a more robust voice synth on a PC, returning a better-sounding audio clip for playback.

Check out the video below to see a short clip of Rudolph in action.

Continue reading “Rudolph toy hacked to announce incoming email”

Physical email notification


One day computers will exist in every part of our lives. You’ll be standing in the shower, lathering up  when Chantal, your holographic computer controlled AI partner, informs you in a cool voice you have a new email. How splendid, it must be the office letting you know there is no work today! “Anything else?” You ask; “Negative” her electronically synthesized voice responds.

Over at TINYenormous they’ve made this dream come true – minus the holographic computer controlled AI partner bit. Rather its simply a physical email notification system consisting of an LED and Arduino with some python code. We like the concept but prefer our Google Desktop with Gmail setup instead. Perhaps by using a small wireless server and rechargeable batteries, it could make a great dinner table centerpiece notifying you of the latest email. How simple, or how complicated would you make a setup?

[Thanks Madmaze]


Rob created a very nice USB version.

Dan made a wireless version from XBee modules and includes an LCD.

J4mie is the original inspiration for the project.

Have your own notification system? Tell us in the comments, And we’ll place it here!