Many cell phones now have the ability to receive email. While that can be very useful, large messages are often a problem both because they are hard to read and because one large message may be split up into multiple messages at the phone.
Sometimes, though, it's important that certain messages get to you even though they may be large. That's the situation one of my Mitel (E-Smith) mail server customers had: mail sent to a certain account was very important to know about, but he didn't want the entire message shipped to his cell phone. As it turns out, this was an easy problem to solve.
One of the features of Qmail is support for "dash addresses", in other words an ordinary account name followed by a "-" and some other word. I talked about this a bit in Mitel (E-Smith) SME Server Mail Forwarding and Lists but these have a use here also.
The first thing to do is to arrange an account that we'll use for this notification. I called it "notify". Just add a user "notify" as you ordinarily would through the admin control panel. Next, we're going to modify the user who gets the important mail. We can do that either by having that user also forward a copy to our "notify" user, or by turning that name into a group that includes the real user and our "notify" user. In either case, we then change "notify" so that its mail actually gets forwarded to "notify-sms". You can do all this through the normal administrative web panels; no "Unix" required yet. Note also that we only created "notify", not "notify-sms".
Now we do have to drop to the dreaded command line. In "notify"'s home directory (cd ~notify) we need to create .qmail-sms for the address "notify-sms" to work. In there we need just one simple line:
|/home/e-smith/files/users/notify/notify.pl
That's a pipe symbol followed by the address of a simple Perl program that handles the actual work:
#!/usr/bin/perl
while (<>) {
$subject=$_ if /^Subject/;
$from=$_ if ( /From/ and not $from);
$date=$_ if ( /^Date:/ and not $date);
}
chomp $subject;
$subject =~ s/'//;
$subject =~ s/"//;
exit 0 if $from =~ /DAEMON/;
exit 0 if $from =~ /notify/;
@recip=("2165551212\@messaging.nextel.com","2165551213\@messaging.nextel.com");
foreach (@recip) {
open(MAIL,"|/bin/mail -s '$subject' $_");
print MAIL <<EOF;
Mail to "notify":
$date
$from
$subject
EOF
close MAIL;
}
Any mail sent to "notify-sms" goes to this program instead, and nowhere else. This simple script extracts the Subject, Date, and From lines and simply creates a new email message to one or more recipents. Technically "Subject" lines can span multiple lines; if you wanted to be sure to get all related lines this would need to be more complex, but for this usage the first would be all we'd want anyway.
That's it. This concept can be expanded to handle all sorts of special mail handling tasks: junk mail filtering, special automatic replies, etc.
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.
Click here to add your comments
Don't miss responses! Subscribe to Comments by RSS or by Email
Click here to add your comments
If you want a picture to show with your comment, go get a Gravatar