OpenSMTPD Getting Started [FAQ Index]


smtpd is enabled by default and reads its configuration from the /etc/mail/smtpd.conf file at boot time. Note that while /etc/mail/smtpd.conf is the default and is loaded by the system rc(8) scripts, it is just a text file loaded and interpreted by the smtpd(8) daemon. Its format is documented in smtpd.conf(5). Additional configuration files may be loaded by using the include keyword:
include "/etc/mail/smtpd.conf.local"
The configuration file consists of options and rules to control how smtpd(8) works, and to allow the selective accepting or rejecting of messages based on information gathered during the SMTP session.

Blank lines are ignored and lines beginning with a hash mark (#) are treated as comments. Lines may be split using the backslash (\) character. Macros can also be used to reduce the complexity of the configuration.

Macros are user-defined variables that can hold IP addresses, port numbers, interface names, etc. Macro names cannot be reserved words (such as port) and may only contain letters, digits, and underscores. A macro is referred to by preceding its name with a dollar character ($). The following creates and uses a recursive macro named all_mx:

mx1 = ""
mx2 = ""
all_mx = "{" $mx1 $mx2 "}"

listen on $all_mx
The validity of the configuration file can be checked with the following command:
# smtpd -nf /etc/mail/smtpd.conf


smtpd(8) operation can be managed using the smtpctl(8) program. For example, the following two commands will show the currently queued mails and the runtime statistics:
# smtpctl show queue
# smtpctl show stats
Updates of some internal smtpd(8) counters can be displayed in one second intervals with the following command:
# smtpctl monitor
The following commands show another example. They will first temporarily stop accepting incoming SMTP sessions, as well as local and remote mail deliveries, then resume them all and bring smtpd(8) back to normal operation:
# smtpctl pause smtp
# smtpctl pause mda
# smtpctl pause mta

# smtpctl resume smtp
# smtpctl resume mda
# smtpctl resume mta
For a complete list of commands, see the smtpctl(8) man page.