home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


sendmail

sendmailSearch this book
Previous: 3.1 Role in the Filesystem Chapter 3
The Roles of sendmail
Next: 3.3 Role in Network Transport
 

3.2 Role in Local Delivery

Another role of the sendmail program is to deliver mail messages to local users. A local user has a mailbox on the local file system. Delivering local mail is done by appending a message to the user's mailbox, by feeding the mail message to a program, or by appending the message to a file other than the user's mailbox.

In general, sendmail does not put mail messages directly into files. You saw the exception in the aliases file, in which you could specifically tell sendmail to append mail to a file. This is the exception, not the rule. Usually, sendmail calls other programs to perform delivery. Those other programs are called delivery agents.

In your sendmail.cf file you found two lines that defined local delivery agents, the ones that sendmail used to deliver mail to the local file system:

Mlocal,    P=/bin/mail, F=lsDFMAw5:/|@rmn, S=10, R=20/40,
Mprog,     P=/bin/sh, F=lsDFMeu, S=10, R=20/40, D=$z:/,

The /bin/mail program is used to append mail to the user's mailbox. The /bin/sh program is used to run other programs that handle delivery.

3.2.1 Delivery to a Mailbox

The configuration file line that begins with Mlocal defines how mail is appended to a user's mailbox file. That program is usually /bin/mail but can easily be a program such as deliver (1) or mail.local (8).

Under UNIX a user's mailbox is a single file that contains a series of mail messages. The usual UNIX convention (but not the only possibility) is that each message in a mailbox begins with the five characters " From  " (the fifth is a blank space) and ends with a blank line.

The sendmail program neither knows nor cares what a user's mailbox looks like. All it cares about is the name of the program that it must run to add mail messages to that mailbox. In the example that program is /bin/mail . The M configuration lines that define delivery agents are introduced in Chapter 6, The Mail Hub and Delivery Agents , and covered in detail in Chapter 30, Delivery Agents .

3.2.2 Delivery Through a Program

Mail addresses that begin with a | character are the names of programs to run. You saw one such address in the example aliases file:


ftphelp:       "|/usr/local/bin/sendhelp"

Here, mail sent to the address ftphelp is transformed via an alias into the new address |/usr/local/bin/sendhelp . The | character at the start of this new address tells sendmail that this is a program to run rather than a file to append to. The intention here is that the program will receive the mail and do something useful with it.

The sendmail program doesn't run mail delivery programs directly. Instead, it runs a shell and tells that shell to run the program. The name of the shell is listed in the configuration file in a line [5] that begins with Mprog :

[5] In actuality, delivery agent definitions often span multiple lines. You'll see this in Chapter 6 .

Mprog,     P=/bin/sh, F=lsDFMeu, S=10, R=20/40, D=$z:/,

In this example the shell is the /bin/sh (1). Other programs can appear in this line such as /bin/ksh (1), the Korn Shell, or smrsh (1), the sendmail restricted shell that is supplied with the source distribution.


Previous: 3.1 Role in the Filesystem sendmail Next: 3.3 Role in Network Transport
3.1 Role in the Filesystem Book Index 3.3 Role in Network Transport