SMS 1.06 - E-Mail notification reformatter
A tool for sending information on incoming e-mails.
This program is distributed under the terms of the GNU GPL (GENERAL PUBLIC LICENSE).
Copyright © 1998-9 by Robert Wagner <email@example.com>
Any errors found in this documentation, comments or remarks are welcome - just drop me a mail. This document may contain information more topical than provided in the "readme" in sms.zip.
So please refer to this page for latest documentation and information on SMS.
Disclaimer: You could cause immense trouble creating mail loops with this utility. So take care of any confirmation
mails for SMS correctly transmitted. Also double-check whether your script
always terminates and doesn't cause hundreds of running processes (Your admin won't
find these things amusing at all...)
Consider yourself disclaimed!
Idea: Why not get notified of incoming E-Mails using Short Messages (SMS) with your
cellnet phone or a pager? Various services provide sending those messages for free
from within the web or have their pagers accessible by individual E-Mail adresses.
Send information about the sender of the latest mail, its subject,
and the total number of mails waiting in your mailbox to your cellnet phone/pager, whenever
new mail arrives. Therefore you'll have to execute this script in your .forward file, which
is the execution method of choice.
Some nifty features - my all-singing, all-dancing SMS-notification tool :-)
The script needs three files to offer some additional features. These are a "killfile",
a "history" file and a "quiet mode" file.
Some important things...
The script takes E-Mail adresses of all users who have ever sent you mail into a history file.
Note that every of those adresses will appear only once in the history. Now why that?
Because a history file may help you determine nasty bulk mailers and other candidates to put
into a killfile. You'll be not informed about mails from any address which appears in the
killfile. This helps avoiding information about incoming bulk mail or mail you do not want
to be informed of.
Another useful feature is the "quiet mode". If you have some of your E-Mail addresses
being forwarded to one mailserver which you want to run my script on, you may not want to be
informed about mail being sent to one or more of your adresses. Listing them in the "quiet
mode" file will tell the script not to send out an notification in that case.
Why waste any capacities? SMS can be up to 160 characters in length. So my script attaches the
beginning of the mail body to the string being sent. However, it tries to omit any greeting formula.
Now you know all the features and possibilities of my little script. You'll have to do some minor configuring though - specify where the killfile, the 'quiet'-file and the history-file are - they must be there, whether you're using them or not. Even if they're zero-byte file-dummies :) Keep in mind that the history-file has to be writable by the script, all three files have to be readable furthermore.
The next thing you have to specify is the absolute path of some UNIX tools. Perhaps I'll implement their functionality in pure Perl code one day, but at the moment I don't have the time, so these UNIX tools are essential. See 'Installation' for details.
By the way: I strongly recommend you strolling through the code. Keep an eye on any comments.
- Make sure the first line of the script points to your copy of Perl 5.
- Edit the Configuration Parameters at the start of the file, i.e.
specify where your UNIX tools are located. The script needs the following UNIX tools:
mail(1) (you might want to use Mail(1) or mailx(1) instead), head(1),
wc(1) and formail(1) from the procmail(1) package. These tools should be available
on every UNIX system.
If you're unsure where these tools are located, you may check this out by executing
the which(1) command. See which(1) for details.
The mailtool is needed to determine how many mails are in your mailbox. Therefore it is important
that it knows the -H option to return the mails' headers. If you're unsure whether your mailtool has got that feature, you may alternatively use the
from(1) command for that purpose. For our needs, from does exactly the same as mail -H. See the code for a simple way of doing this.
- At the end of the script you'll have to choose one procedure for sending the information. I currently provide one for sending via MTN (send_string_mtn), Omnipoint (send_string_omnipoint) and Pagers or other electronics which can be reached by sending an e-mail (send_string_quix). Simply let the script use the appropriate procedure and comment out the other ones. Please mind that you'll have to do some minor configuring in 'your' procedure, i. e. inserting the right cellnet phone number for SMS or pager's e-mail address. Of course you may also implement you own sendmail or WWW dump routine for sending the string generated. This may either be a system call of your mailtool, giving it the string generated as parameter (in this case you can comment out the two lines for encoding), or a dump of the information into an WWW form. I'd advise you to utilize lynx for that purpose. If you write any other sending procedures, I'd be glad if you send them to me, so I can implement them into further distributions.
- Used files. There are some data files providing some user comfort. SMS writes all senders
of mail it processed into the file specified in "$history". If there are
some senders you do not want to be notified of, you can put their e-mail
adresses in the file specified in "$killfile". If you do not want to be
notified of mails sent to a particular address (in case you get mails sent to
different e-mail addresses of yours on one account), write them in the
file specified by "$quiet". "$mailbox" should indicate your mailbox file. Please note that all these
three files have to exist, no matter if you use them or not, i. e. you have to create at least
three empty text files and specify them in the script.
- The script contains features to send part of the mail body itself. However, it deletes the
'Hello Robert', or whatever greeting formula the mail contains. You therefore might want to replace
[Rr]obert in the regex with your first name :-)
- Please study all the comments in the code carefully.
Oh yeah - I just wrote a "quick and dirty" tool providing killfile and history maintenance. It analyses
the history and asks the user whether to put any of the names listed into the killfile, leave them in the history,
or delete them. Of course it avoids multiple entries. I included it in distribution of "SMS".
version 0.07 (97/06/17) written in ksh
version 0.42 (97/10/24) with additional perl code for separating sender's address
version 0.70 (98/01/09) re-written in perl
version 1.00 (98/01/09) basic running version
version 1.01 (98/01/10) minor modifications, tr(1) no more required
version 1.02 (98/01/15) bugfixes, slightly more elegant coding
version 1.05 (98/01/19) from as alternative for mailtool, inserted MTN SMS gateway example
version 1.06 (98/01/23) different sending methods implemented (MTN, Quix/via e-mail, Omnipoint)
© 1998 Robert Wagner,
SMS 1.06 - E-Mail notification reformatter.
Copyright © 1998 Robert Wagner. All rights reserved.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for