Using Protocol Rules in Bindings

Using Protocol Rules in Bindings

You can use the Rule property in each event binding's Source property bag to further refine conditions in which a sink is notified of an event. These rules are made up of protocol conditions that must match the protocol commands that are sent when the message (or the appropriate header) is submitted to the bound sink that will be notified. The conditions themselves are case-insensitive patterns, and can include * wildcards. The format of each rule is as follows:

<command> = <pattern>

You can have multiple conditions in a single rule, separated by semicolons:

<command1>=<pattern>;<command2>=<pattern2>

SMTP Binding Rules

For sinks bound to SMTP OnArrival events, you can define rules that must match the EHLO, MAIL FROM, or RCPT TO protocol commands. If the message arrives in the pickup directory, the MAIL FROM command is derived from either the Sender message header. if present, or the From message header. The RCPT TO command comes from the To, CC and BCC headers for the message.

When creating conditions for the MAIL FROM or RCPT TO protocol commands, you match e-mail addresses. E-mail address patterns consist of two parts—a name and a host and domain:

<name pattern>[@domain pattern>]

The brackets indicate the optional host and domain portion of the address. The name pattern conditions are structured as follows:

<name pattern> := { * | [*]<email name>[*]}

For example,

*      ' any name
*user  ' any name ending with "user"
user*  ' any name starting with "user"
*user* ' any name containing the string "user"

Domain pattern conditions are structured as follows:

<domain pattern> := [*][<domain name>]

For example,

*   ' matches any domain
example.com  ' exactly matches example.com
*example.com ' any domain that ends with example.com, including "example.com"

When creating rules for the EHLO command, only use the domain condition.

Here are some complete examples of various SMTP conditions:

MAIL FROM=*                    ' match any email address
RCPT TO=person@example.com   ' match person@example.com exactly
RCPT TO=person@*example.com  ' match person@anywhere.example.com
MAIL FROM=*person              ' match anyperson@example.com
RCPT TO=name*@*le.com   ' match <anything>@<any>.example.com
EHLO=example.com        ' match EHLO example.com
EHLO=*example.com       ' match EHLO from <any>.example.com
EHLO=*                    ' not very useful, but causes all messages to fire events.

Note that all conditions are case-insensitive. That is

mail from=user  same as MAIL from=USER same as MAIL FROM=UsEr

Multiple conditions can be set for each rule, separated by a semicolon. For example,

Mail From=*@fake.example.com;EHLO=fake.example.com;RCPT TO=Group*@*example.com

This rule runs only if:

  1. The EHLO protocol command for the transmitting client comes from the fake.example.com domain.
  2. The MAIL FROM protocol command specifies an address within the fake.example.com.
  3. One of the recipients defined with the RCPT TO protocol command is an e-mail address starting with the string "Group" and has a domain that ends with the string "example.com."

NNTP Binding Rules

For sinks bound to NNTP OnPost, OnPostEarly, and OnPostFinal events, you can define rules that must match the message's Newsgroups, subject, organization, and control mail header field values:

Newsgroups=*
Newsgroups=alt.*
Sender=*@example.com
Subject=*
Organization=*
control=*

As demonstrated earlier, you can use * wildcards for the entire newsgroup name or portions of the name. Note that the NNTP sink binding rules are not based upon protocol commands; they are based upon mail header fields present in each message.