How to Customize the sendmail.cf File on a VPS1


The days of editing the sendmail.cf file by hand are behind us. The recommended method of customizing the configuration file is to use a macro configuration (mc) file and m4 macros. Here is how it works on VPS version 1.

Step 1. vinstall sendmail

To get a recent copy of the m4 macros shipped by sendmail.org, issue the following command:


% vinstall sendmail

Vinstalling sendmail doesn't modify your current sendmail configuration or executable in any way. All it does is create the directory ~/usr/local/sendmail and some subdirectories that contain m4 macros used to create custom sendmail.cf files.

The directory ~/usr/local/sendmail/cf/cf contains the following files--including 4 working sendmail.cf files.


  Build
  Makefile
  README
  default.cf
  default.mc
  default-procmail-lda.cf
  default-procmail-lda.mc
  default-auth-only.cf
  default-auth-only.mc
  default-procmail-lda-auth-only.cf
  default-procmail-lda-auth-only.mc

You can probably use any one of them "as is" by copying it to ~/etc/sendmail.cf. The file ~/usr/local/sendmail/cf/cf/README includes the following information about the sample files:

A. default.cf (generated from default.mc)

If you are using the same sendmail.cf that came with your VPS, then this file will give the same functionality. It:

(Note: If you have vinstalled SpamAssassin, do not use this file! It will disable SpamAssassin because this configuration file does not use procmail as its local delivery agent. If you use SpamAssassin, use default-procmail.lda.cf instead!)

B. default-procmail-lda.cf (generated from default-procmail-lda.mc)

Identical to the default.cf file, except that it uses procmail for the local delivery agent.

This file is compatible with SpamAssassin and procmail.

C. default-auth-only.cf (generated from default-auth-only.mc)

Like default.cf, except that users who wish to relay e-mail through the mail server must configure their e-mail client to authenticate with SMTP AUTH. (This one does not support POP before SMTP authentication.)

This file is not compatible with SpamAssassin and procmail. (See the next one.)

D. default-procmail-lda-auth-only.cf (generated from default-procmail-lda-auth-only.mc)

Identical to the default-procmail-lda.cf file, except that users who wish to relay e-mail through the mail server must configure their e-mail client to authenticate with SMTP AUTH.

This file is compatible with SpamAssassin and procmail.

Step 2. Make a Working Copy of the mc File Selected Above

It is common to name the working copy based on the name of your mail server:


% cd ~/usr/local/sendmail/cf/cf
% cp default.mc mail.vmailpros.com.mc

Step 3. Edit the mc File, If Necessary

If you want to add some FEATURE's or define statements to the mc file, do it now. (Features and definitions are described in the file ~/usr/local/sendmail/cf/README, as well as in the sendmail book (O'Reilly, 2003; ISBN 1-56502-839-3) and on the Sendmail.org web site.) You might not need to modify the mc file, however.

To edit the file, choose your favorite editor (pico, vi and emacs immediately come to mind) and make modifications.


% pico mail.vmailpros.com.mc

Step 4. Generate a sendmail.cf File from the mc File

With ~/usr/local/sendmail/cf/cf as your current directory, issue the command:


% ./Build mail.vmailpros.com.cf

substituting your own working file name (up to the "mc" suffix), ending in "cf".

Step 5. Back up Your Existing sendmail.cf File

In case the new file doesn't work:


% cp ~/etc/sendmail.cf ~/etc/sendmail.cf.save

Step 6. Copy the New sendmail.cf to Replace the Old One

Something like the following:


%cp ~/usr/local/sendmail/cf/cf/mail.vmailpros.com.cf ~/etc/sendmail.cf

Step 7. Make Sure sendmail Still Works

Send some e-mail to and from your mail server and make sure that it is delivered. Check ~/var/log/messages if necessary.

If something doesn't work, restore the sendmail.cf you saved in step 5 and start over ...