HREF="http://www.sendmail.org/m4/basics.html">
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:
divert(-1)dnl # # This file contains definitions for mailserver.yourdomain.com # divert(0)dnl
The divert(-1) tells m4 to ignore the following text until the next divert. This serves as a comment for your own notes.
VERSIONID(`@(#)mailserver.mc 1.0 (yourdomain.com) 5/1/97')
This defines the version number of your mc file. It will create a comment header in the generated sendmail.cf for reference.
OSTYPE(solaris2)dnl
The OSTYPE(solaris2)
command simply
includes the file cf/ostype/solaris2.m4
. Each operating system
has its own quirks, such as the location of the alias or help files. You can
see a list of the available operating system types by looking in the directory
cf/ostypes/
. Choose the name which best matches your operating
system.
DOMAIN(yourdomain.com)dnl
Like the OSTYPE()
command, the
DOMAIN(yourdomain.com)
command simply
includes the contents of the file cf/domain/yourdomain.com
. You
can use this to create global settings for all mc files you create for your
domain. This line and the associated file are optional but recommended if you
are creating more than one configuration for your domain. See below for more
information about the domain file.
MAILER(local)dnl MAILER(smtp)dnl
These are the mailers to include in the sendmail configuration. In this
example, we are including the local and program mailer (MAILER(local)
) and the smtp family of
mailers (MAILER(smtp)
). The
available mailers are described in a separate document.
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.
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.