= Distributed James Server &mdash; Matchers
:navtitle: Matchers

This documentation page lists and documents Matchers that can be used within the
Distributed Server MailetContainer in order to write your own mail processing logic with out-of-the-box components.

== Supported matchers

include::partial$All.adoc[]

include::partial$AtLeastPriority.adoc[]

include::partial$AtMost.adoc[]

include::partial$AtMostPriority.adoc[]

include::partial$DLP.adoc[]

include::partial$FetchedFrom.adoc[]

include::partial$HasAttachment.adoc[]

include::partial$HasException.adoc[]

include::partial$HasHeader.adoc[]

include::partial$HasHeaderWithPrefix.adoc[]

include::partial$HasMailAttribute.adoc[]

include::partial$HasMailAttributeWithValue.adoc[]

include::partial$HasMailAttributeWithValueRegex.adoc[]

include::partial$HasMimeType.adoc[]

include::partial$HasMimeTypeParameter.adoc[]

include::partial$HasPriority.adoc[]

include::partial$HostIs.adoc[]

include::partial$HostIsLocal.adoc[]

include::partial$IsMarkedAsSpam.adoc[]

include::partial$IsOverQuota.adoc[]

include::partial$IsRemoteDeliveryPermanentError.adoc[]

include::partial$IsRemoteDeliveryTemporaryError.adoc[]

include::partial$IsSenderInRRTLoop.adoc[]

include::partial$IsSingleRecipient.adoc[]

include::partial$IsSMIMEEncrypted.adoc[]

include::partial$IsSMIMESigned.adoc[]

include::partial$IsX509CertificateSubject.adoc[]

include::partial$RecipientDomainIs.adoc[]

include::partial$RecipientIs.adoc[]

include::partial$RecipientIsLocal.adoc[]

include::partial$RecipientIsRegex.adoc[]

include::partial$RelayLimit.adoc[]

include::partial$RemoteAddrInNetwork.adoc[]

include::partial$RemoteAddrNotInNetwork.adoc[]

include::partial$RemoteDeliveryFailedWithSMTPCode.adoc[]

include::partial$SenderDomainIs.adoc[]

include::partial$SenderHostIs.adoc[]

include::partial$SenderIs.adoc[]

include::partial$SenderIsLocal.adoc[]

include::partial$SenderIsNull.adoc[]

include::partial$SenderIsRegex.adoc[]

include::partial$SentByJmap.adoc[]

include::partial$SentByMailet.adoc[]

include::partial$SizeGreaterThan.adoc[]

include::partial$SMTPAuthSuccessful.adoc[]

include::partial$SMTPAuthUserIs.adoc[]

include::partial$SMTPIsAuthNetwork.adoc[]

include::partial$SubjectIs.adoc[]

include::partial$SubjectStartsWith.adoc[]

include::partial$TooManyRecipients.adoc[]

include::partial$UserIs.adoc[]

include::partial$XOriginatingIpInNetwork.adoc[]

== Experimental matchers

include::partial$AttachmentFileNameIs.adoc[]

include::partial$CommandForListserv.adoc[]

include::partial$CommandListservMatcher.adoc[]

include::partial$CompareNumericHeaderValue.adoc[]

include::partial$FileRegexMatcher.adoc[]

include::partial$HasHabeasWarrantMark.adoc[]

include::partial$InSpammerBlacklist.adoc[]

include::partial$NESSpamCheck.adoc[]

include::partial$SenderInFakeDomain.adoc[]

== Composite matchers

It is possible to combine together matchers in order to create a composite matcher, thus simplifying your
Mailet Container logic.

Here are the available logical operations:

* *And* : This matcher performs And conjunction between the two matchers: recipients needs to match both matcher in order to
match the composite matcher.
* *Or* : This matcher performs Or conjunction between the two matchers: consider it to be a union of the results.
It returns recipients from the Or composition results of the child matchers.
* *Not* : It returns recipients from the negated composition of the child Matcher(s). Consider what wasn't
in the result set of each child matcher. Of course it is easier to understand if it only
includes one matcher in the composition, the normal recommended use.
* *Xor* :  It returns Recipients from the Xor composition of the child matchers. Consider it to be the inequality
operator for recipients. If any recipients match other matcher results
then the result does not include that recipient.

Here is the syntax to adopt in *mailetcontainer.xml*:

....
<processor state="transport" enableJmx="true">
    <matcher name="relay-allowed" match="org.apache.james.mailetcontainer.impl.matchers.Or">
        <matcher match="SMTPAuthSuccessful"/>
        <matcher match="SentByMailet"/>
        <matcher match="org.apache.james.jmap.mailet.SentByJmap"/>
        <matcher match="RemoteAddrInNetwork=127.0.0.1, 10.2.*, 193.50.151.*"/>
    </matcher>

    <!-- ... -->

    <mailet match="relay-allowed" class="ToProcessor">
        <processor>relay</processor>
    </mailet>
</processor>
....