使用清單中的文字、 片語或模式為基礎的路由電子郵件的郵件流程規則Use mail flow rules to route email based on a list of words, phrases, or patterns

若要協助您遵守貴組織的電子郵件的使用者,您可以使用 Exchange 傳輸規則來決定如何路由傳送電子郵件,其中包含特定字詞或模式。簡短的單字或片語清單,您可以使用 Exchange 系統管理中心。針對較長的清單中,您可能會想要使用 Windows PowerShell 的 Exchange 模組以文字檔案中讀取清單。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

如果清單中的文字、 片語或模式為 long,您可以將其置於中含有每個字、 片語或圖樣的文字檔案在其專屬行。使用 Windows PowerShell 的 Exchange 模組清單中的關鍵字讀入變數、 建立傳輸規則,並將使用關鍵字變數指派給傳輸規則條件。例如,下列指令碼會從呼叫 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.