Send Email Updates through SMS
I had the idea of sending myself an SMS message anytime I received an email. I know that can be overbearing for some, and even me for my non-personal email. Since I don’t really get anything but person-to-person emails there, I figured it would be worth it to try. Also, I got my cellphone before AT&T Wireless was bought up by Cingular. Therefore I’m still on an old AT&T plan which doesn’t charge for incoming SMS messages, so it wouldn’t cost me anything. I’m running my personal email through a hosting company (DreamHost), so I decided to try using procmail to do it. Another option was to rely on a client to forward the messages. While this may be straightforward for some, I had no experience at all in procmail. Read on to see how I got it to work.
First thing was to find out what email address I could use to send SMS messages to my phone. This page lists what many phone companies use as their e-mail addresses for the cellphone numbers. I also had a bit of fun testing to make sure that it would work. I did find out that if I tried to send an email that was too large for a text message, it wouldn’t send anything. This meant that I had to trim down the message if it was too large. To make it easy for my first shot, I decided that I should just remove the body and only send the original sender and the subject line.
Next up was to learn a little procmail magic. I had a little fun getting the DreamHost end of the it all working because they seem to prefer that you use the web interface. After messing around and looking up many online resources and samples, I came up with this script.
:0c * ! ^X-Loop: sms_procmail | (formail -X "Subject:" -X "From:" -I "X-Loop: sms_procmail" -X "X-Loop:" -I "To: 8005551212@mmode.com" -X "To:" ; echo "--Body Removed--" ) | /usr/lib/sendmail -oi -t
I’ll try to describe it line by line. The first line is just procmail syntax to start a ‘recipe’, a mail processing directive, and do the recipe on a message copy. The next line (”* ! ^X-Loop…”) says to ignore any email that has the header ‘X-Loop: sms_procmail’. This is to prevent email loops caused by repeatedly sending the message around and around. This shouldn’t happen, but everyone says it’s good practice. The lines that start with a pipe (’|') are actions to perform. The ‘formail’ command does work on the incoming mail. The ‘-X’ options tell which email headers to include (extract) from the original. The ‘-I’ options insert headers, overwriting previous headers. The whole formail command brings just the subject and adds the correct To: field and the loop-preventing field. The echo line is partially to tell me that there will be no body added. However, I found that I had to put something there otherwise the subject line wouldn’t show up in the resulting SMS message. The final line is actually send the message using sendmail.
I sent a few testing emails and it works great! The lag between sending the message from GMail and a notification on my phone is generally under 20 seconds. Not too bad, considering all the loops that are being leapt through.
My next idea is to try to trim the body and possibly send the actual body if it’s less than 100 characters. I’m not sure how interesting that would be though. How many emails really only have 100 characters in the body? I don’t think that many. But then again, how many people really need to have an immediate SMS update of an email? I don’t think that many. I actually don’t even think I’m one of them
.
February 9th, 2008 at 10:23 am
dockers mailing address
April 28th, 2008 at 6:21 am
updates on it field
June 5th, 2008 at 7:52 pm
12