FreeBSD sendmail Frequently Asked Questions

  1. Why not use the instructions from sendmail.org's distribution?
  2. Where can I find general (non-FreeBSD-specific) sendmail information?
  3. How do I modify my sendmail.cf file?
  4. What is the best way to regenerate aliases, virtusertable, and other database/map files?
  5. How do I start sendmail?
  6. How do I stop sendmail?
  7. How do I restart sendmail?
  8. How do I make sendmail start automatically when I reboot?
  9. How do I make procmail my local delivery agent?

1. Why not use the instructions from sendmail.org's distribution?

When they apply, you should use the instructions that ship with the vanilla sendmail.org distribution. These FAQs address some of the areas where FreeBSD's implementation diverges from the distribution.

2. Where can I find general (non-FreeBSD-specific) sendmail information?

3. How do I modify my sendmail.cf file?

Make modifications to the sendmail configuration file (sendmail.cf) by first editing a macro configuration (mc) file. Then generate a new sendmail.cf from the macro configuration file.

  1. As root, change to the /etc/mail directory by issuing the command:
    
    # cd /etc/mail
    
  2. If this is the first modification to the sendmail.cf on this machine, you will need to create a working macro configuration file. You can do this by typing:
    
    # make 
    
    If you aren't sure whether you have a working mc file, issue the command hostname to find your server's name. Then type ls to list the files in the /etc/mail directory. If you see a file with a name that begins with your host name and ends with ".mc", then you already have a working mc file, and you can omit this step.

    This initial make command copies the macro configuration file that is shipped with FreeBSD (named freebsd.mc) to the working mc file. (It probably isn't a good idea to modify freebsd.mc directly.)

  3. Edit the <hostname>.mc file with your favorite editor.
    This is the step where you add the FEATURE's, definitions, etc., that appear in the sendmail documentation. Sendmail recommends the following order for mc lines:
    1. VERSIONID()
    2. OSTYPE()
    3. DOMAIN()
    4. option definitions. (Most--but not all--of these start with "define". Two examples:)
           define(`confTO_IDENT',`0')
           INPUT_MAIL_FILTER(`clmilter',`S=local:/var/run/clamav/clmilter.sock, F=, T=S:4m;R:4m')
    5. FEATURE()
    6. macro definitions
    7. MAILER()
    8. ruleset definitions (e.g. LOCAL_RULE_0, Local_check_mail ...)

    If it isn't immediately obvious where to insert an additional line--after carefully reading the above list--try inserting your addition somewhere after the DOMAIN line (or after OSTYPE if your mc file doesn't have a DOMAIN line) and before the MAILER lines.

    Some FEATUREs are "order-dependent"--they must appear (in the mc file) before or after others. If unsure, consult the cf/README.

  4. Generate the sendmail.cf by issuing the following commands:
    
    # make
    # make install
    
    The first make command creates a file named <hostname>.cf from the <hostname>.mc file. The second make command copies <hostname>.cf to sendmail.cf
  5. Restart sendmail so that sendmail will read the new configuration:
    
    # make restart
    
    The make restart command restarts both sendmail daemons (including the submission daemon--which reads the submit.cf rather than sendmail.cf).

4. What is the best way to regenerate aliases, virtusertable, and other database/map files?

After editing the text file(s) from the which the map files are created,


# cd /etc/mail
# make
It is not necessary to restart sendmail after regenerating the "db" files--sendmail detects that they have changed and re-reads them. (For the truly paranoid, however, it probably doesn't hurt anything ... :-)

5. How do I start sendmail?


# cd /etc/mail
# make start

6. How do I stop sendmail?


# cd /etc/mail
# make stop

7. How do I restart sendmail?


# cd /etc/mail
# make restart

8. How do I make sendmail start automatically when I reboot?

Try adding the following lines to /etc/rc.conf:


sendmail_enable="YES"
sendmail_submit_enable="YES"
If you see that sendmail_enable and sendmail_submit_enable are already set in /etc/rc.conf--to values other than "YES"--it might be sufficient to just comment out the lines you find there.

For more possibilities, search for "sendmail" in the file /etc/defaults/rc.conf. "NO" and "NONE" are other possible values for sendmail_enable. If you don't want any sendmail processes started, use "NONE". ("NO" prevents the inbound [MTA] daemon from running, but won't block the submission daemon from running.)

9. How do I make procmail my local delivery agent?

First, install procmail.

Hint: Use the FreeBSD ports tree: cd /usr/ports/mail/procmail; make; make install

Insert the following line in your sendmail macro configuration (mc) file:


FEATURE(local_procmail)
The line must appear earlier in the file than the MAILER(local) directive!
Then regenerate sendmail.cf from the mc file and restart sendmail.

Author

Weldon Whipple <weldon@whipple.org>