Write a Delivery Agent Script
The program that is driven by the prog delivery
agent can be a compiled executable binary, a shell script, or even a
perl(1) script. The limitation on the kind of
program that can be run is made by the sh(1)
shell (if sh -c is used in the
A=) or by execve(2) (if it is
launched directly from the P=). You need to read
the manuals on your system to determine your limitations. For
example, not all versions of sh(1) allow
constructs such as the following in scripts:
#!/usr/local/bin/perl
When this appears as the first line of a script, the
#! tells sh(1) or
execve(2) to run the program whose pathname
follows, to execute the commands in the script.[8]
In writing a program for mail delivery using the
prog delivery agent, some unexpected problems can
arise. We will illustrate, using fragments from a Bourne shell
script.
Duplicates Discarded
When sendmail gathers its list of recipients, it views a program to run as just another recipient. Before performing any delivery, it sorts the list of recipients and discards any duplicates. Ordinarily, this is just the behavior that is desired, but discarding duplicate programs from the aliases(5) file[9] can cause some users to lose mail. To illustrate, consider a program that notifies the system administrator that mail has arrived for a retired user:
#!/bin/sh /usr/ucb/mail -s gone postmaster
This script reads everything (the mail message) from its standard input and feeds what it reads to the /usr/ucb/mail program. The ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access