How to Create a Sandwich Configuration with AXIGEN and an External Filter

This article explains how to create a sandwich-like configuration with AXIGEN and a SMTP-aware external filtering (antivirus/antispam) application

Solution

In our example, AXIGEN will listen on port 25 (on both an external and local interface) and your AV/AS filter mail gateway on another port (i.e. 1025). In order to create the sandwich configuration, you need to edit the SMTP Policy file and add the following code:

event onEhlo{
  # we allow unauthenticated delivery for 127.0.0.1
  if(is(remoteSmtpIp, "127.0.0.1")){
    set(remoteDelivery, "all");
  }
}

event onRcptTo{
  # all mails NOT coming from 127.0.0.1, we relay to port 1025
  if(not(is(remoteSmtpIp, "127.0.0.1"))){
    set(currentRcptRelayHost, "127.0.0.1:1025");
  }
}

A short scheme of the configuration would be the following:
==> axigen:25 --> filter:1025 --> axigen(local):25 ==> delivery
OS: LinuxWindowsFreeBSDMACOpenBSDNetBSDSolaris
Distros: Windows