Share via


Configure a Transport Rule for Messages That Have a Blank Subject

Applies to: Exchange Server 2010

Transport rules perform specified actions on messages based on message properties such as sender, recipients, message scope, message subject, and message body. Creating a transport rule for messages that have a blank subject line requires the use of regular expressions.

Warning

Before you configure new transport rules in your production environment, use a test environment to learn how to create transport rules and test them thoroughly. The following procedures aren't intended to be run in a production environment without modification to support your organization.

Important

For transport rules to be applied to e-mail messages, a route must exist that enables the message to enter and leave a server that applies transport rules. Also, the message must not be subject to an administrator-configured transport restriction that prevents delivery of the message. If a transport restriction prevents delivery of a message, the Transport Rules agent can't act on that message, and no Transport Rules agent events are logged.

The ^$ Regular Expression

To detect messages that have blank subject lines, the following procedures use the ^$ regular expression. This regular expression consists of two pattern strings, ^ and $. Pattern strings are used in regular expressions to match patterns in text that can vary. When the ^ and $ pattern strings are used in this order, the transport rule condition matches only the exact string that's between the two pattern strings. Because there's no string between the ^ and $ pattern strings in the ^$ regular expression, it matches only an empty string, such as a blank subject line.

For more information about regular expressions, see Regular Expressions in Transport Rules.

The RejectMessage Transport Rule Action

The RejectMessage transport rule action is used to reject messages and provide an enhanced status code for the rejection. In this example, the RejectMessage transport rule action is used to reject a message and return a non-delivery report (NDR). The RejectMessage transport rule action is available only on Hub Transport servers.

You can modify the text that's displayed to the sender in the Diagnostic information for administrators section of the NDR. This text can provide helpful information to enable you to understand why the message was rejected.

You can also modify the delivery status notification (DSN) code and message that appears in the user information section of the NDR by specifying a customized DSN code. A customized DSN code is associated with a customized DSN message. It's useful to specify this code so that you can refer the user to an HTML link to a specific policy or regulation. By default, the NDR associated with the 5.7.1 DSN code is sent.

For example, if you want to refer users to the Information Technology department if their message is rejected, you can specify a new, unused, customized DSN code in the EnhancedStatusCode property. After you specify a new customized DSN code, if the customized DSN code isn't already defined, you must use the New-SystemMessage cmdlet to create the DSN code and specify the text that should be displayed when that DSN code is referenced. For an example of how to do this, see Use the Shell to create a transport rule for messages that have a blank subject later in this topic.

Note

The RejectReason transport rule action is available only on Hub Transport servers. If you want to reject messages that have a blank subject line on Edge Transport servers, you must use the SmtpRejectMessage transport rule action. You can only specify the DSN code when you use the SmtpRejectMessage transport rule action. You can't specify an alternative message to display to the user or administrator.
For more information about the SmtpRejectMessage transport rule action, see "Actions Available on an Edge Transport Server" in Transport Rule Actions.

For more information about what values are accepted and how Microsoft Exchange Server 2010 associates a DSN code with a transport rule, see Associate a DSN Message with a Transport Rule.

Use the EMC to create a transport rule for messages that have a blank subject

You need to be assigned permissions before you can perform this procedure. To see what permissions you need, see the "Transport rules" entry in the Messaging Policy and Compliance Permissions topic.

  1. Open the New Transport Rule wizard. Depending on whether you're performing this procedure on a Hub Transport or Edge Transport server, use the following navigation:
    • Hub Transport servers: In the console tree, navigate to Organization Configuration > Hub Transport.
    • Edge Transport servers: In the console tree, click Edge Transport.
  2. In the action pane, click New Transport Rule.
  3. On the Introduction page, complete the following fields:
    1. Name   Type the name for the transport rule.
    2. Comments   (optional) You can use this field to describe the rule's functionality and relevant details. Text in the comments field has no impact on rule functionality.
    3. Enable Rule   New rules are enabled by default. If you want the rule to be created in a disabled state, clear this check box.
  4. On the Conditions page, complete the following fields:
    1. In the Step 1. Select condition(s) box, select the when the Subject field matches text patterns condition.
    2. In the Step 2. Edit the rule description by clicking an underlined value box, click the blue underlined text patterns.
    3. In the Specify text patterns dialog box, type ^$, and then click Add. Click OK to close the dialog box, and then click Next.
  5. On the Actions page, complete the following fields:
    1. In the Step 1. Select actions box, select all the actions that you want to apply to this rule. You must select at least one action to create a transport rule.
    2. In the Step 2. Edit the rule description by clicking an underlined value box, click each blue underlined word.
    3. In the new dialog box that appears, select the items that you want to apply, or type the values manually, and then click OK to close the dialog box.
    4. Repeat the previous step for each action that you selected. After you configure all the actions, click Next.
  6. On the Exceptions page, complete the following fields:
    1. In the Step 1. Select exceptions if necessary box, select all the exceptions that you want to apply to this rule. You don't have to select any exceptions.
    2. If you selected exceptions in the previous step, in the Step 2. Edit the rule description by clicking an underlined value box, click each blue underlined word.
    3. In the new dialog box that appears, select the items that you want to apply, or type the values manually, and then click OK to close the dialog box.
    4. Repeat the previous step for each exception that you selected. After you configure all the exceptions, click Next.
  7. On the Create Rule page, review the Configuration Summary. If you're satisfied with the configuration of the new rule, click New.
  8. On the Completion page, review the following, and then click Finish to close the wizard:
    • A status of Completed indicates that the wizard completed the task successfully.
    • A status of Failed indicates that the task wasn't completed. If the task fails, review the summary for an explanation, and then click Back to make any configuration changes.

Use the Shell to create a transport rule for messages that have a blank subject

You need to be assigned permissions before you can perform this procedure. To see what permissions you need, see the "Transport rules" entry in the Messaging Policy and Compliance Permissions topic.

This example creates the transport rule Blank Line Rule to reject messages that have a blank subject. The rule uses the enhanced status code 5.7.1 and includes the explanatory text "The message has a blank subject field."

New-TransportRule -Name "Blank Line Rule" -Enabled $true -SubjectMatchesPatterns '@("^$")' -RejectMessageReasonText "The message has a blank subject field." -RejectMessageEnhancedStatusCode "5.7.1"

This example creates the transport rule Blank Line Rule to reject messages that have a blank subject on a Hub Transport server. The rule uses the customized DSN code 5.7.228 and includes the explanatory text "Messages must have a subject in the subject line or they are rejected."

Note

When using a customized DSN code, you must define the DSN code and customized message using the New-SystemMessage cmdlet. For more information, see Associate a DSN Message with a Transport Rule.

New-TransportRule -Name "Blank Line Rule" -Enabled $true -SubjectMatchesPatterns '@("^$")' -RejectMessageReasonText "Messages must have a subject in the subject line or they are rejected." -RejectMessageEnhancedStatusCode "5.7.228"

This example creates a customized DSN code and message.

New-SystemMessage -DsnCode 5.7.228 -Internal $True -Language En -Text "This message was rejected because it did not have a subject in the subject line. For more information, please contact the Information Technology department."

For detailed syntax and parameter information, see New-TransportRule or New-SystemMessage.