Skip to content

Beutlin/howto-opensmtpd-filters-and-reports

Repository files navigation

Howto use filters / reports in OpenSmtpd

Since release 6.4.0 OpenSmtpd has support for external filters.
It takes some time to understand its concept.
Here is a small showcase about it.

Quickstart

  1. Install OpenSMTPD
  2. Create a simple smtpd.conf
filter afilter proc-exec "/usr/bin/python3 /tmp/afilter/afilter.py"
listen on eth0 port smtp filter { afilter } 
action "inbound" mbox
action "outbound" relay filter {afilter}
match from any for local action "inbound"
match from local for any action "outbound"
  1. Copy afilter.py and afilter_utils.py to the right location.
  2. Start smtpd: smtpd -f smtpd.conf -d
  3. Test your SMTP server: swaks -f [email protected] -t [email protected] -s localhost -ehlo home.local
  4. Watch your output:
  • Request: OpenSmtpd -> Filter color is purple
  • Response: OpenSmtpd <- Filter color is green 6See results complete log in /tmp/opensmtpd_afilter.log

How does it work?

alt text

See also: ./sample_log.txt

Some ideas

  1. Implement abstract methods like FilterSmtpIn->mail_from(ctx, address)
class ReportSmtpIn(IReportSmtpIn):
    @staticmethod
    def link_connect(ctx, rdns, fcrdns, src, dest):
        # your implementation
        pass
  1. Listen only for special reports / filters
hooks = [
    ReportSmtpIn.link_connect, ...
]

Further links:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages