Using procmail to avoid text message fees

Occasionally, I use the email-to-SMS gateway for my mobile phone. The only problem with doing this is email message size. If the message is too large, the Cingular email-to-SMS gateway breaks it up into many SMS messages, eating up a chunk of my monthly text allotment.

To combat this, I’ve cobbled together a procmail formula that forwards only the first 120 characters of the message to a mobile gateway. I drew the formula originally from some old postings to a monharc message board, to give credit where due. My rule follows (include in your .procmailrc or designated procmail rule file):

:0c
# First, set your procmail rule conditions
* ^TO_<conditional>
* ^Subject:.*<conditional>
{
# Now, clean the message and keep only the first 120 chars.
:0fbw
| tr -s '\011\012 ' ' ' | cut -c 1-120

# Finally, send the copy to the email-to-SMS gateway
:0
! <yournumber>@mobile.mycingular.com
}

To implement this rule, you’ll need a basic understanding of procmail. Also interesting is that while Cingular states the text message size is 160 characters, I found that sending over 140 characters resulted in message breakup most times. Therefore I picked 120 characters to give myself a margin of error. Hope this helps you save some money, especially now that Cingular is raising text message prices by 50%.

Tags: ,

Leave a comment