HREF="http://www.sendmail.org/m4/basics.html"> sendmail.org

Using m4 to configure sendmail

Configuring sendmail by hand can be one of the most difficult tasks a system administrator faces. However, the m4 configuration tools included in the sendmail distribution simplify this task.

In order to use the tool, you must create one or more files which will contain the instructions for building your sendmail.cf.

cf/cf/mailserver.mc

First, read the cf/README file thoroughly. It will give you instructions on creating a .mc file in the cf/cf directory. Your mailserver.mc file will typically look something like:

divert(-1)dnl
#
#  This file contains definitions for mailserver.yourdomain.com
#
divert(0)dnl
VERSIONID(`@(#)mailserver.mc     1.0 (yourdomain.com) 5/1/97')
OSTYPE(solaris2)dnl
DOMAIN(yourdomain.com)dnl
FEATURE(virtusertable, `dbm /etc/virtusertable')dnl
MAILER(local)dnl
MAILER(smtp)dnl

This file consists of the following parts:

cf/domain/yourdomain.m4

As described above, the domain file contains information that is global for all mail configurations in your domain. Although it is optional, it is recommended for sites that will be creating more than one configuration. A typical cf/domain/yourdomain.com.m4 file looks something like:

divert(-1)dnl
#
#  This file contains the global definitions for yourdomain.com
#
divert(0)dnl
VERSIONID(`@(#)yourdomain.com.m4   1.0 (yourdomain.com) 5/1/97')
define(`confPRIVACY_FLAGS', `authwarnings,goaway')dnl
FEATURE(use_cw_file)dnl

It may have some other FEATURE()'s and define()'s as well. The available features and variable definitions are described in their own document.

Generating the cf file from the mc file

Now that you have created a generic mailserver.mc and possibly a yourdomain.com.m4 domain file, you are ready to have m4 build a sendmail.cf file. This is accomplished with the commands shown below:

cd sendmail-VERSION/cf/cf
m4 ../m4/cf.m4 mailserver.mc > obj/mailserver.cf

You can now look over obj/mailserver.cf and test it if necessary using sendmail's test mode:

sendmail -bt -C obj/mailserver.cf

Although most anything you need to do can be accomplished with the m4 tool, you may need to tweak the results for your site. Doing so requires a basic understanding of the different sections of a sendmail.cf file. As described above, there are many different features and options can you set in your domain and mailserver.mc files. Start with the generic configuration shown above and slowly add these customizations until you have everything setup they way you want it.

home