Полезная информация

sendmail

sendmailSearch this book
Previous: 7.1 OverviewChapter 7
Macros
Next: 7.3 Predefined Macros
 

7.2 Defining Macros

In the previous chapter you roughed out delivery agent definitions for the hub and local delivery agents. Notice that the last part of each, the A= command-line part, ended with a macro:

V7
# Delivery agent definition to forward mail to hub  
Mhub,   P=[IPC], S=0, R=0, F=mDFMuXa, T=DNS/RFC822/SMTP, A=IPC $h
# Sendmail requires this, but we won't use it.
Mlocal, P=/bin/mail, F=lsDFMAw5:/|@rmn, S=0, R=0, A=mail -d $u
                                                            -^
                                                          macros

There are two kinds of macros: those that you define and those that sendmail defines. Macros that begin with uppercase letters, such as R and {REMOTE}, are ones that you optionally define. Those that begin with a lowercase letter, such as h and u, are ones that sendmail either defines or requires you to define.

You have already seen an example of an uppercase macro:

D{REMOTE}mailhost

This gives the macro named {REMOTE} the value mailhost.

Somewhere on your network, there may be a machine whose alias is mailhost or something similar, such as mailrelay. This is the alias of the machine that serves your site's mail hub. If no such alias exists, you must use an actual machine name (such as mail.us.edu). Now edit \%client.cf, and add your first macro, {REMOTE}:

V7
# Defined macros                                          <- new
D{REMOTE}mailhost         # The name of the mail hub      <- new
                                                          <- new
# Delivery agent definition to forward mail to hub
Mhub,   P=[IPC], S=0, R=0, F=mDFMuXa, T=DNS/RFC822/SMTP, A=IPC $h
# Sendmail requires this, but we won't use it.
Mlocal, P=/bin/mail, F=lsDFMAw5:/|@rmn, S=0, R=0, A=mail -d $u

Here, three new lines have been added to the client.cf file. The first is a comment, and the third is a blank line to visually separate macro definitions from delivery agent definitions. The second line is the new macro definition. As the comment says, this {REMOTE} macro will contain as its value the name of the host to which all mail will be forwarded.

Take a moment to test this new version of the client.cf file:

% ./sendmail -Cclient.cf -bt </dev/null

The sendmail program reads and parses the client.cf file. There are no errors in the client.cf file, so sendmail prints no error messages.


Previous: 7.1 OverviewsendmailNext: 7.3 Predefined Macros
7.1 OverviewBook Index7.3 Predefined Macros