My phone is now an email notifier

If you send a mail to my “real” email address (not any of the ones I use for businesses and other non-people), it will now get sent to my mobile phone as an SMS. Unless it’s between 1AM and 8AM, then it won’t. Only the first few lines get sent, and it uses the sender’s email address as the sender for the SMS.

I use gmail to read all my mail these days, and I even have their mobile phone app on my phone, so in theory I can even reply from my phone. I set this up because GMail notifier on the Mac doesn’t work if the screensaver is active. Which is when I MOST want it to work. It’s really dumb. I could run or some other pop mail program and let it notify me, but I don’t want to just on principle. I couldn’t find a simple pop notifier that worked with gmail.

Plus I figure it’ll be nice to get a notification of “real” email no matter where I am too. At least until I get tired of my phone beeping all the time. Before I switched to gmail, this would’ve been completely unreasonable, but gmail’s spam filter is excellent. I’m not worried about floods of spam making it to my phone.

Update: with a few more real world messages having passed through the system, something bizarre about my cell phone provider’s system emerged.  Any message that contains “href=” at all will not be forwarded to my phone.  “href” is fine, “foo=” is fine, URLs themselves are fine.  But  not “href=”.  So HTML email with links failed.  The fact that it was a spam that made it by GMail’s filter doesn’t mean I wasn’t annoyed that my system failed to work :).  I fixed it now, but I didn’t update the instructions.  That can’t possibly be true for everyone.  I just added a “| sed ‘s/href=/href:/'” into each procmail rule.

Read more for the full MacGyver details

fetchmail to get mail off my gmail account via POP (which thankfully doesn’t mark the mail read!)

procmail with these rules:

PHONE=[email to sms gateway address for my phone]
FROM_=`formail -rt -xTo: | expand | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`
SUBJ_=`formail -c -xSubject:
         | expand
         | sed -e 's/  */ /g'
         | sed -e 's/^[ ]*//g' -e 's/[ ]*$//g'`

* ^
* ^Content-type:.*boundary.*
| formail -k -X Content-type: | stripmime | head -4 | timecheck mailsend -smtp smtp -t $PHONE -sub "$SUBJ_" -f "$FROM_"

* ^
| formail -I "" | head -4 | timecheck mailsend -smtp smtp -t $PHONE -sub "$SUBJ_" -f "$FROM_"

timecheck script:

let hour=`date +%H`

if (($hour < 1 || $hour > 7)); then
	exec $cmd "$@"

mailsend program
stripmime program

Now where’s my iPhone already? 🙁


Saturday, April 28th, 2007 Uncategorized

Leave a Reply