Unix Network Admin   «Prev  Next»
Lesson 7Configuring sendmail with M4
ObjectiveUse 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 sendmail.
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 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.
VERSIONID(`@(#)generic-solaris2.mc 8.3 
(Berkeley) 3/23/96')

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:
  1. FEATURE keyword statements turn on and off special features of sendmail.
  2. DOMAIN keyword statements control per-domain behavior for machines that handle multiple domains.
  3. MASQUERADE keywords control address rewriting and masquerading.
  4. MAILER keywords select particular mail delivery agents and transfer protocols.
Let us look at a specific Example Configuration File before attempting an exercise.

Configure m4 sendmail - Exercise

Click the Exercise link belowto create sendmail.cf using M4.
Configure m4 sendmail - Exercise