faq

How do I integrate MIMEDefang with OpenSMTPD?

MIMEDefang is integrated with OpenSMTPD through filter-mimedefang.pl, a native OpenSMTPD filter (see smtpd-filters(7)) distributed as Mail-MIMEDefang-OpenSMTPD. smtpd starts the filter itself, and the filter talks directly to mimedefang-multiplexor, so the mimedefang milter daemon is not used. Your mimedefang-filter(5) runs unchanged.

Step 1: Install the filter, either from CPAN:

cpan Mail::MIMEDefang::OpenSMTPD

or from the release tarball:

perl Makefile.PL
make
make test
make install

filter-mimedefang.pl is installed in /usr/local/libexec/smtpd, where smtpd looks up a relative proc-exec path. If it ends up elsewhere (for example with INSTALL_BASE or local::lib), use its full path in smtpd.conf.

Step 2: Start mimedefang-multiplexor with your filter. By default, the OpenSMTPD filter expects its socket at /var/spool/MIMEDefang/mimedefang-multiplexor.sock:

mimedefang-multiplexor -s /var/spool/MIMEDefang/mimedefang-multiplexor.sock \
    -f /etc/mail/mimedefang-filter [other options]

Step 3: Declare the filter in /etc/mail/smtpd.conf and apply it to your listener(s):

filter "mimedefang" proc-exec "filter-mimedefang.pl" user _mdefang group _mdefang
listen on all filter "mimedefang"

The filter only runs the message checks by default. Add options to run the earlier callbacks: -r for filter_relay, -H for filter_helo, -s for filter_sender and -t for filter_recipient. Use -m and -z if the multiplexor socket or the spool directory are not in the default location:

filter "mimedefang" proc-exec "filter-mimedefang.pl -r -H -s -t" user _mdefang group _mdefang

Step 4: Make sure the user the filter runs as (_mdefang above) can read and write the multiplexor socket and the MIMEDefang spool directory.

Step 5: Check and reload the configuration:

smtpd -n && rcctl reload smtpd

If the multiplexor cannot be reached within the timeout (-T, default 30 seconds), mail is tempfailed with a 451.

Limitations: smtpd-filters(7) cannot change the envelope once a message has been accepted. As a result, add_recipient(), delete_recipient(), change_sender() and action_sm_quarantine() are not available, the tarpit delay from filter_relay() and the related callbacks is ignored, and action_discard() is ignored. These requests are logged at "warning" level and the mail is delivered.

See filter-mimedefang.pl(1) for all options and the Sendmail macros (TLS, authentication) the filter passes to MIMEDefang.