Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Postfix Documentation
Previous Page Home Next Page

Configuring the Postfix SMTP pass-through proxy feature

In the following example, the before-filter Postfix SMTP server gives mail to a content filter that listens on localhost port 10025. The after-filter Postfix SMTP server receives mail from the content filter via localhost port 10026. From then on mail is processed as usual.

The content filter itself is not described here. You can use any filter that is SMTP enabled. For non-SMTP capable content filtering software, Bennett Todd's SMTP proxy implements a nice PERL/SMTP content filtering framework. See:

Internet -> Postfix SMTP server on port 25 -> filter on localhost port 10025 -> Postfix SMTP server on localhost port 10026 -> Postfix cleanup server -> Postfix incoming queue

This is configured by editing the file:

    # =============================================================
    # service type  private unpriv  chroot  wakeup  maxproc command
    #               (yes)   (yes)   (yes)   (never) (100)
    # =============================================================
    # Before-filter SMTP server. Receive mail from the network and
    # pass it to the content filter on localhost port 10025.
    smtp      inet  n       -       n       -       20      smtpd
    # After-filter SMTP server. Receive mail from the content filter
    # on localhost port 10026.
    # inet n  -       n       -        -      smtpd

Note: do not specify spaces around the "=" or "," characters.

The before-filter SMTP server entry is a modified version of the default Postfix SMTP server entry that is normally configured at the top of the file:

  • The number of SMTP sessions is reduced from the default 100 to only 20. This prevents a burst of mail from running your system into the ground with too many content filter processes.

  • The "-o smtpd_client_connection_count_limit=10" prevents one SMTP client from using up all 20 SMTP server processes. This limit is not necessary if you receive all mail from a trusted relay host.

    Note: this setting is ignored by the stable Postfix 2.1 release. The feature will be available only in the experimental release until Postfix 2.2.

  • The "-o smtpd_proxy_filter=" tells the before filter SMTP server that it should give incoming mail to the content filter that listens on localhost TCP port 10025.

  • Postfix 2.3 supports both TCP and UNIX-domain filters. The above filter could be specified as "inet:". To specify a UNIX-domain filter, specify "unix:pathname". A relative pathname is interpreted relative to the Postfix queue directory.

The after-filter SMTP server is a new entry:

  • The "" makes the after-filter SMTP server listen on the localhost address only, without exposing it to the network. NEVER expose the after-filter SMTP server to the Internet :-)

  • The "-o smtpd_authorized_xforward_hosts=" allows the after-filter SMTP server to receive remote SMTP client information from the before filter SMTP server, so that the after-filter Postfix daemons log the remote SMTP client information instead of logging localhost[].

  • The other after-filter SMTP server settings avoid duplication of work that is already done in the "before filter" SMTP server.

By default, the filter has 100 seconds to do its work. If it takes longer then Postfix gives up and reports an error to the remote SMTP client. You can increase this time limit (see configuration parameter section below) but doing so is pointless because you can't control when the remote SMTP client times out.

Postfix Documentation
Previous Page Home Next Page