使用邮件流规则根据字词、短语或模式的列表路由电子邮件Use mail flow rules to route email based on a list of words, phrases, or patterns

若要帮助您的用户遵守您组织的电子邮件策略,则您可以使用 Exchange 传输规则来确定包含特定字词或模式的电子邮件的路由方式。对于字词或短语的简短列表,您可以使用 Exchange 管理中心。对于较长的列表,您不妨将 Exchange 模块用于 Windows PowerShell,读取文本文件中的列表。To help your users comply with your organization's email policies, you can use Exchange transport rules to determine how email containing specific words or patterns is routed. For a short list of words or phrases, you can use the Exchange admin center. For a longer list, you might want to use the Exchange Module for Windows PowerShell to read the list from a text file.

如果您的组织使用数据丢失防护 (DLP),请参阅数据丢失防护,了解用于识别和路由包含敏感信息的电子邮件的其他选项。If your organization uses Data Loss Prevention (DLP), see Data loss prevention for additional options for identifying and routing email that contains sensitive information.

示例 1:使用包含不可接受字词的简短列表Example 1: Use a short list of unacceptable words

如果您的字词或短语列表较短,则您可以使用 Exchange 管理中心创建规则。例如,如果您要确保所有发件人发送的电子邮件中均不含有关您公司名称、内部首字母缩略词或产品名称的不善言语或拼写错误,则可以创建一个规则来阻止此类邮件并通知发件人。请注意,字词、短语和模式不区分大小写。If your list of words or phrases is short, you can create a rule using the Exchange admin center. For example, if you want to make sure no one sends email with bad words or with misspellings of your company name, internal acronyms or product names, you could create a rule to block the message and tell the sender. Note that words, phrases, and patterns are not case sensitive.

此示例可阻止含常见拼写错误的邮件。This example blocks messages with common typos.

基于文本模式显示阻止某封邮件的规则

示例 2:使用包含不可接受字词的较长列表Example 2: Use a long list of unacceptable words

如果您的词、 短语或模式列表很长,您可以将它们放在每个词、 短语或模式与文本文件在自己的行。使用 Exchange 用于 Windows PowerShell 模块中的关键字列表读取到变量、 创建传输规则,并将与关键字变量分配给传输规则条件。例如,以下脚本从调用 misspelled_companyname.txt 文件所需的拼写错误的列表。If your list of words, phrases, or patterns is long, you can put them in a text file with each word, phrase, or pattern on its own line. Use the Exchange Module for Windows PowerShell to read in the list of keywords into a variable, create a transport rule, and assign the variable with the keywords to the transport rule condition. For example, the following script takes a list of misspellings from a file called misspelled_companyname.txt.

$keywords=Import-Content  .\misspelled_companyname.txt
New-TransportRule -Name "Block messages with unacceptable words" -SubjectOrBodyContainsWords $keywords -SentToScope "NotInOrganization" -RejectMessageReasonText "Do not use internal acronyms, product names, or misspellings in external communications."

使用文本文件中的短语和模式Using phrases and patterns in the text file

文本文件可以包含用于各种模式的正则表达式。这些表达式不区分大小写。常见的正则表达式包括:The text file can contain regular expressions for patterns. These expressions are not case-sensitive. Common regular expressions include:

表达式Expression
匹配Matches
.
任何单个字符Any single character
\*
任何其他字符Any additional characters
\d\d
任何十进制数字Any decimal digit
[ character_group ][ character_group ]
character_group 中的任何单个字符。Any single character in character_group .

例如,此文本文件中包含 Microsoft 的常见拼写错误。For example, this text file contains common misspellings of Microsoft.

[mn]sft
[mn]icrosft
[mn]icro soft
[mn].crosoft

若要了解如何使用正则表达式指定模式,请参阅正则表达式参考To learn how to specify patterns using regular expressions, see Regular Expression Reference.