automatically sending text messages from email messages

| 1 Comment | No TrackBacks
Using the natty little webtext script (updated to use an $HOME/.webtextrc file for the username/password) and a little bit of procmail magic, we can now send messages containing the subject line of a specific email message once it has been received.
Firstly, there's the .procmailrc file. The recipe I'm using looks like:
# send text messages
:0 W
* ^subject: IM:
| $HOME/bin/sendim
The script sendim is a simple bash script that checks the subject line contains "IM: " and then sends on the remainder of the subject line as a text message to my mobile phone.
As a security precaution, I've added a special header 'X-apikey' which is checked by the sendim. If the apikey doesn't match then the rule doesn't fire. You should replace the XXX item with your own value generated using echo <some text here> | sha1sum. By not putting the api check in the .procmailrc file you can quietly drop messages that don't have the correct key instead of keeping them in your inbox.
#!/bin/bash -p

export PATH=$HOME/bin:$PATH

subject=
apikey=
apikey_c="XXX"

while read foo; do
    [[ -z $foo ]] && break
    subject=${subject:-$(echo $foo | sed -n "s/[sS]ubject: IM: //p")}
    apikey=${apikey:-$(echo $foo | sed -n "s/X-apikey: //p")}
done

if [[ -n $subject && $apikey = $apikey_c ]]; then
    webtext -t 'YYY' "$subject" >/dev/null 2>&1
fi

Source of sendim. Don't forget to replace the XXX and YYY with your chosen items.

No TrackBacks

TrackBack URL: http://www.petesh.com/scgi-bin/MT/mt-tb.cgi/228

1 Comment

Leave a comment

About this Entry

This page contains a single entry by Pete Shanahan published on February 10, 2009 7:17 PM.

Consistency checking a block device was the previous entry in this blog.

Fragmentation percentage FAIL is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.