Hardware Reference
In-Depth Information
E-mail
E-mail is now the lifeblood of personal and professional life the world over. It is very easy to send and receive
messages from anyone at any time—too easy, in fact, as the state of most spam folders will testify! But it is here to stay,
so we can add e-mail to the list of protocols our house will support, allowing us to send messages to our video, light
switches, or TV, and for our house to send messages back.
Preparing E-mail in Linux
The travel path of an e-mail is the same everywhere and consists of three parts:
u Mail transfer agent (MTA) : The MTA is also known as the e-mail server and is the software that
communicates with other MTAs over the Simple Mail Transfer Protocol (SMTP) to route the
e-mail messages it receives to the correct recipient, noting the destination address and passing
it to the server on that machine.
u Mail retrieval : This is the method by which e-mail is transferred from the mail server and onto
the client. The transfer of this data occurs through either Post Office Protocol (POP) or Internet
Message Access Protocol (IMAP). In our case, these will be on the same machine because we'll
run our own MTA, but they needn't be as we could also download our Google Mail to our local
machine for processing, as I'll cover in Chapter 6.
u Mail user agent (MUA) : This is the client software used to actually read the e-mail as well as
send it. This includes large GUI applications such as Thunderbird, web mail solutions such as
AtMail, and smaller console-based ones such as Mutt.
Although corporate drones will bleat incessantly about the benefits of Exchange as an MTA
( http://en.wikipedia.org/wiki/Comparison_of_mail_servers ), you have four primary e-mail servers to choose
from and many more MUAs than simply Outlook. Furthermore, because of the design of Linux (and Unix-like systems
in general), you can automatically process incoming mail with great flexibility and issue noninteractive commands to
send replies.
Each MTA has benefits and features the others don't. The big four—Exim, qmail, Postfix, and Sendmail—each
has its own advocates and detractors. I personally use Exim because it has a guided install and “just worked”
afterward. For alternate opinions, there is a wiki page covering the latest versions of these packages, along with some
commercial offerings. I'll wait here while you install one of them.
Sending E-mail
After installing the server and testing it by sending yourself (and a second user) an e-mail or two, you can begin
the short task of writing an automatic send script. This is the easiest thing to do with Linux and involves the mail
command, which sends e-mail with any number of additional headers and settings. Here, you need only an
abstraction script such as the following:
#!/bin/bash
SUBJECT=$1; shift
TOADDR=$1; shift
MSG=$*
echo "$MSG" | mail -s "$SUBJECT" "$TOADDR"
Search WWH ::




Custom Search