Pushing Corporate Email out to Wireless Devices
For the most part, email is delivered to employees' desktop computers. However, what happens when important email is delivered and one of the key decision makers is out of the office? Or if a meeting at 2 P.M. is cancelled, but some of the attendees are offsite when the cancellation email is delivered? To address these issues, many companies extend email to wireless devices like pagers, cell phones, and PDAs, allowing urgent and timely email to reach recipients no matter where they are. This article will explain how Sendmail can be linked with wireless messaging software to push email out to wireless devices.
Quality of Service
Several wireless carriers provide email gateways where you can send an email to pin_number@wireless_carrier.com. This is sometimes convenient, however, it lacks the necessary control and reliability when wireless email messages are a mission-critical part of a company's way of doing business. As an alternative, companies use wireless messaging software that can provide robust logging, fail-over, and analysis. In this article, I will discuss extending Sendmail to use as a wireless messaging engine that provides the QoS features needed for corporate communications. For the sake of the examples, I'll refer to generic messaging software as msg_sw.
Extending Sendmail to Wireless Devices
Most UNIX hosts utilize Sendmail for managing the delivery of email messages. Messaging software can be integrated tightly with the Sendmail facility. Before performing this integration, you will need to decide which of the following integration strategies is best for you:
Dedicated Email Address for Each Pager
- Provide a different dedicated email address for each pager. All email sent to the given email address will be automatically forwarded to the pager.
- Perform text pattern matching on incoming email for individual email accounts and selectively forward email to the individual's pager.
The Sendmail alias file provides a mechanism for routing email to a program. Messaging software utilizes this facility to allow forwarding of messages to pagers. The Sendmail alias file (normally located at /etc/aliases) has the following format:
my-pager-email-alias: |"/usr/local/msg_sw/bin/email_wrapper mypager"
The email address my-pager-email-alias is a valid email address. If a message is sent to this address, the entire email will be piped to the program (or shell script) shown after the pipe symbol in quotes, (e.g., /usr/local/msg_sw/bin/email_wrapper). I'll show an example of an email wrapper script shortly. Note that mypager is the recipient's pager name.
Once you have created an alias for each of your pagers, you must compile the aliases file using the newaliases command. Usually, typing newaliases with no parameters or argument as root will compile your alias file. See your UNIX man pages for help in running this command. You will also need to create a wrapper script that will parse the email and send it to the pager using your messaging software. The following is a sample wrapper script for this purpose:
if [ "$1" = "" ]
echo "usage: email_wrapper <pagername>"
# this line sends the message body to the
# messaging software (msg_sw) command line program
sed -e '1,/^$/ d' | /usr/local/msg_sw/bin/msg_sw $1 -
This script will strip the header from the email and send the body of the message to the pager that was given as the argument to the script. Place this script in /usr/local/msg_sw/bin/email_wrapper (this path will vary from site to site) to be consistent with the Sendmail alias defined above. The email_wrapper sends the email message to the msg_sw command, which will queue the message and send it to the desired carrier.
Selectively Forwarding Email Based on Text Pattern Matching
Using the email utility, procmail, you can send email to pagers based on certain criteria, like a keyword in the email's subject line. If you haven't used procmail before, you should get acquainted with it. It is an extremely powerful tool that can be used for many different purposes. For this application, we will forward emails to procmail and use its powerful string matching capability to selectively forward email onto your messaging software.
Start by creating a file named .forward in the user's home directory as follows:
# forward all email to procmail
This .forward file forwards all incoming email to the procmail tool.
You will need to create a file named .procmailrc in the user's home directory. A good first step for testing is:
# send selected messages to the pager
|/usr/local/msg_sw/bin/msg_sw mypager -
# all email placed in spooling file for normal reading
In this case, we perform a pattern match on each incoming email and, if the subject of the email contains the string pager, it will be forwarded to the pager mypager. The 1Hbc code is interpreted as follows:
Following the code line, we see the pattern match line, followed by the action line. The action line starts with the pipe character | indicating the output should be piped to the msg_sw command for forwarding to the pager. Additionally, we also put all of the incoming email into the normal email spooling file so the users can read the email with their favorite email program as usual. The second control code :0 is interpreted as follows:
- 1 -- One pattern match line follows
- H -- Perform the match on the email header only
- b -- Pipe the body of the email only to the pager
- c -- Carbon copy the email so it shows up for email reading as well
Following the code line, we see the pathname for the email spooling file to which procmail will append all email.
- 0 -- No pattern match lines, process unconditionally
The two email-to-wireless device integration methods described above are specific to the UNIX Sendmail program. However, this general email-to-wireless messaging engine integration can be accomplished with almost any email program. The email program just needs to support a mechanism for passing an email message to a program. Most UNIX email software supports this. Once the integration is complete, the corporate mobile workforce is ready to be looped into corporate communications, instantly and anywhere.
About the Author
Pam Rissman is vice president of customer support and services at MobileSys, Inc. (http://www.mobilesys.com). MobileSys develops very reliable and highly scalable wireless messaging solutions for UNIX and Windows NT platforms.