Policy Script 2: Scan External Mail for Viruses

# attr NAME=Mail from external hosts
else {
    pmx_add_header "X-PMX-Version" "%%PMX_VERSION%%";
    pmx_mark "Size" "%%MESSAGE_SIZE%%";
    # attr NAME=Clean mail containing viruses
    if pmx_virus {
        pmx_file "Virus";
        pmx_virus_clean "cantclean.tmpl";
        pmx_replace_header "Subject" "[PMX:VIRUS] %%SUBJECT%%";
        pmx_replace_header "X-PerlMx-Virus-Detected" "%%VIRUS_IDS%%";


  • If the if pmx-relay test is "false", and the else control is executed:
    • Mail is assumed to be from an external host.
    • The pmx_add_header command adds a header to the message. The header includes the string " X-PMX-Version " and the PureMessage version (which is added using the %%PMX_VERSION%% template variable.)
    • The size of the message is then written to the message log. The %%MESSAGE_SIZE%% template variable is substituted for the actual size of the message, in bytes.
  • The pmx_virus command tests the message for virus threats. If the test is "true", and the message contains a virus:
    • pmx_file copies the message to the quarantine with the reason "Virus". This action does not affect the delivery of the message.
    • The pmx_virus_clean action attempts to clean the virus from the message. If cleaning fails, the message is quarantined, and a message is sent to the recipient based on the specified failure template file, cantclean.tmpl.
    • The pmx_replace_header command prefixes the "Subject" header with " [PMX:VIRUS] ". The original "Subject" is added to the end of the header with the %%SUBJECT%% template variable.
    • The pmx_replace_header command then adds, or alters, a "X-PerlMx-Virus-Detected" header. The %%VIRUS_IDS%% template variable adds the found virus IDs to the message header.