Default Internal Hosts Treatment

Although mail from external hosts is the primary concern for most sites, it is also common to establish a policy for internal hosts. For example, if you want to create a rule for internal hosts that rejects all messages containing a virus, use the following code:

if pmx_relay :memberof "internal-hosts" {
 pmx_mark1 "i";
        
 if pmx_virus {
      reject "One or more viruses were detected in the message.";
      stop;
 }
}

If the pmx_relay test returns true (that is, if the hostname or IP address of the server matches an entry in the "Internal hosts" list), the message is marked with an "i", which is added to the message log to indicate that this policy rule was hit.

If the pmx_virus test returns true, the message is rejected for the reason that it contains one or more viruses.

Some sites choose to implement a rule that accepts mail from hosts and senders included in the Whitelisted hosts or Whitelisted senders lists. This snippet contains the following code:

if anyof(pmx_relay :memberof "whitelisted-hosts",
             envelope :memberof "From" "whitelisted-senders",
             envelope :memberof "From" "whitelisted-senders-per-user")
   {
            keep;
            stop;
}

This rule accepts a message and stops processing if (a) the hostname or IP address matches an entry in the list of Whitelisted hosts, (b) the contents of "Envelope from" are included in the Whitelisted senders list, or (c) the contents of "Envelope from" are included in the Whitelisted senders (per-user) list.