|Lesson 7||Configuring sendmail with M4 |
|Objective||Use M4 and a template file to create sendmail.cf automatically. |
Configure sendmail with M4
Configuration files for
sendmail versions 8.7 and higher can be
assembled from a set of template files. The template files are written in a macro language called M4. M4 has been developed by the Free Software Foundation GNU project and can be obtained without charge from the GNU project. Most recent UNIX distributions include M4. Fortunately, it is not necessary to know much about how M4 works to use it to configure
If you have installed the latest
sendmail version yourself, then the M4 templates for the
sendmail configuration file are organized in the subdirectory cf of the
sendmail source directory. For future reference, let us call this directory
SENDMAILSRC. On Linux, these files are located under /usr/lib/sendmail-cf, so you could use the following command to simplify the pathname:
Assembling a configuration file
You create a sendmail.cf file by beginning with one of the template files (which have extension mc) in the SENDMAILSRC/cf directory. These files
have names such as generic-solaris2.mc (for solaris) or redhat.mc (for RedHat linux).
Here is the file SENDMAILSRC/cf/generic-solaris2.mc:
# This is a generic configuration file for
# SunOS 5.x (a.k.a. Solaris 2.x)
# It has support for local and SMTP mail
# only. If you want to customize it,
# copy it to a name appropriate for your
# environment and do the modifications there.
Notice the sequence of keywords (OSTYPE, DOMAIN, MAILER). You must customize this file by modifying the arguments to these keywords so that
sendmail operates the way you want it to.
There are literally hundreds of potential keywords and arguments that you can place into a .mc file, reflecting the vast array of options and
potential email configurations. See the README files in the SENDMAILSRC directory and its subdirectories or consult the sendmail FAQ for more
information. The keywords fall into categories. Some examples include:
Lets look at a specific configuring.sb example before attempting an
FEATURE keyword statements turn on and off special features of
DOMAIN keyword statements control per-domain behavior for machines that handle multiple domains.
MASQUERADE keywords control address rewriting and masquerading.
MAILER keywords select particular mail delivery agents and transfer protocols.
Click the Exercise button to create sendmail.cf using M4.
Configure m4 sendmail - Exercise