Injecting Custom Headers in Xeams


When running Xeams in Firewall mode, occasionally, you may want to insert custom headers allowing the downstream server to apply additional filtering. Consider the following use case where this feature is applicable.

  • You use a shipping company that generates emails on your behalf and sends an email to your clients once the package is shipped. It also sends a BCC copy of the same message to an address in your company.
  • You want these BCC messages to go in a shared Inbox on your MS Exchange, which is sitting behind Xeams.
  • The shipping company sends their emails from a single IP address.
  • You want Xeams to add a special header to this email whenever a message is received from the IP address of this partner.
  • The following diagram demonstrates the message flow.

Prerequisites

You must be using build 6240 or higher.

Assumptions

  • Assume you want Xeams to add the following header whenever an email comes in from 50.60.70.80
    X-PrintingPartner:yes
  • You will create a rule in Exchange, which is the downstream server after Xeams, to put messages with this header in a shared inbox.

Steps

  • Create a new file in $INSTALL_DIR/config folder called CustomHeaderInjector.xml
  • Paste the following contents
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<customHeaderInjector>
    <!--
    Following is a valid list of injectorType:
    1 - Sender's IP address
    2 - Sender's Email address, which appears in SMTP envelope (MAIL FROM)
    3 - Host name of the connecting IP address
    4 - HELO string specified during SMTP communication
    5 - Recipient's address, which appears in RCPT TO
    
    Following is a valid list of operators:
    0 - Equals
    1 - Ends with
    2 - Starts with
    3 - Missing
    
    -->
    <injectors>
        <!--
        Example of an email that comes in from a partner. It puts a header with a YES value.
        -->
        <injector friendlyName="PrintingPartner" injectorType="1" operator="1">
            <searchFor><![CDATA[50.60.70.80/32]]></searchFor>
            <headerName>X-PrintingPartner</headerName>
            <headerValue>yes</headerValue>
        </injector>
        
    </injectors>
</customHeaderInjector>
  • Restart Xeams after creating or modifying this file.
  • Xeams should now insert the desired header into every email from 50.60.70.80