MHonArc Resources: MSGEXCFILTER

[Prev: MSGBODYEND] | [Resources][TOC] | [Next: MSGFOOT]

# MSGEXCFILTER

## Syntax

Envariable

  `M2H_MSGEXCFILTER=`Perl_expressions

Element

  `<MSGEXCFILTER>`
  Perl_expressions
  `</MSGEXCFILTER>`

Command-line Option

  `-msgexcfilter` Perl_expressions

## Description

MSGEXCFILTER may be used to define Perl expressions to selectively exclude messages during an ADD operation. Unlike the CHECKNOARCHIVE resource, MSGEXCFILTER allows you to explicitly examine entire message headers to determine which messages should be added.

When defining the expressions, the raw message header will be in the `$_` variable. If the last evaluated expression of MSGEXCFILTER returns a true value, or there is an explicit `return` statement that returns a true value, MHonArc will exclude the message.

## Default Setting

Nil.

## Resource Variables

N/A

## Examples

A typical usage of MSGEXCFILTER is to define a pattern match operation:

    <MsgExcFilter>
    /^From: .*\behood@/im;
    </MsgExcFilter>

Here, we are excluding any messages that are from "ehood". The "`m`" modifier to the pattern match exists because the header will contain newlines.

The following example attempts to exclude all messages not addressed to `mhonarc-users@mhonarc.org`:

    <MsgExcFilter>
    !/\bmhonarc-users@mhonarc.org\b/i;
    </MsgExcFilter>

Here, we do what the CHECKNOARCHIVE resource basically does:

    <MsgExcFilter>
    /^restrict:\s+no-external-archive/im ||
    /^x-no-archive:\s+yes/im;
    </MsgExcFilter>

## Version

2.4.1

## See Also

ADD, CHECKNOARCHIVE

[Prev: MSGBODYEND] | [Resources][TOC] | [Next: MSGFOOT]