测试邮件流规则Exchange OnlineTest mail flow rules in Exchange Online

在 Exchange Online 组织或没有 Exchange Online 邮箱的独立 Exchange Online Protection (EOP) 组织中,应先测试新的邮件流规则 (也称为传输规则) ,然后再启用这些规则。In Exchange Online organizations or standalone Exchange Online Protection (EOP) organizations without Exchange Online mailboxes, you should test new mail flow rules (also known as transport rules) before you turn them on. 这样,如果您意外创建了一个条件,无法准确执行您所需的操作或以意外的方式与其他规则进行交互,也不会给您带来任何意外结果。This way, if you accidentally create a condition that doesn't do exactly what you want or interacts with other rules in unexpected ways, you won't have any unintended consequences.

重要

创建规则后至少等待 30 分钟,然后再进行测试。Wait at least 30 minutes after creating a rule before you test it. 如果您创建规则后立即进行测试,可能会产生不一致的行为。If you test immediately after you create the rule, you may get inconsistent behavior.

步骤 1:在测试模式下创建规则Step 1: Create a rule in test mode

备注

DLP 和策略提示在独立 EOP 中不可用。DLP and policy tips are not available in standalone EOP.

通过选择测试模式,您可以在不执行影响邮件流的任何操作的情况下,评估规则的条件。您可以设置一个规则,以便在匹配规则时收到电子邮件通知,您也可以查看查看邮件跟踪查找符合该规则的邮件。有两种测试模式:You can evaluate the conditions for a rule without taking any actions that impact mail flow by choosing a test mode. You can set up a rule so that you get an email notification any time the rule is matched, or you can look at the Look at the message trace for messages that might match the rule. There are two test modes:

  • 不使用策略使用技巧 测试:此模式与事件报告操作一同使用,每次电子邮件匹配规则时,你都可以收到一封电子邮件。Test without Policy Tips: Use this mode together with an incident report action, and you can receive an email message each time an email matches the rule.

  • 使用 策略使用技巧 测试:此模式仅在使用数据丢失防护 ( DLP) 时可用,在某些 Exchange Online 和 Exchange Online Protection (EOP) 订阅计划中可用。Test with Policy Tips: This mode is only available if you're using Data loss prevention (DLP), which is available with some Exchange Online and Exchange Online Protection (EOP) subscription plans. 使用此模式时,当发件人发送的某封邮件匹配策略时,邮件将发送给发件人,但未执行任何邮件流操作。With this mode, a message is set to the sender when a message they are sending matches a policy, but no mail flow actions are taken.

下面是匹配规则时将看到的内容(如果包含事件报告操作):Here's what you'll see when a rule is matched if you include the incident report action:

检测到规则时发送消息

在测试模式下使用事件报告操作Use a test mode with an incident report action

  1. 在 Exchange 管理中心 (EAC) 中,转到 “邮件流”>“规则”In the Exchange admin center (EAC), go to Mail flow > Rules.

  2. 创建新规则,或选择现有的规则,然后选择“编辑”。Create a new rule, or select an existing rule, and then select Edit.

  3. 向下滚动到“为此规则选择模式”部分,然后选择“不使用策略提示测试”或“使用策略提示测试”。Scroll down to the Choose a mode for this rule section, and then select Test without Policy Tips or Test with Policy Tips.

  4. 添加事件报告操作:Add an incident report action:

    1. 选择 "添加操作";如果看不到,请选择"更多选项",然后选择"添加操作"。 Select Add action, or, if this isn't visible, select More options, and then select Add action.

    2. 选择“生成事件报告并将它发送到”。Select Generate incident report and send it to.

    3. 单击 "选择一个...", 然后选择自己或其他人。Click Select one... and select yourself or someone else.

    4. 选择“包括邮件属性”,然后选择您希望包含在收到的电子邮件中的任何邮件属性。Select Include message properties, and then select any message properties that you want included in the email you receive. 如果未选择任何属性,在规则匹配时仍会收到一封电子邮件。If you don't select any, you will still get an email when the rule is matched.

  5. 选择“保存”。Select Save.

步骤 2:评估规则是否执行您所希望的操作Step 2: Evaluate whether your rule does what you intend

要测试规则,您可以发送足够的测试邮件以确认您预期的情况发生,或查看邮件跟踪中是否有您组织的人员发送的邮件。确保评估下列类型的邮件:To test a rule, you can either send enough test messages to confirm that what you expect happens, or look at the message trace for messages that people in your organization send. Be sure to evaluate the following types of messages:

  • 您希望与规则匹配的邮件Messages that you expect to match the rule
  • 您不希望与规则匹配的邮件Messages that you don't expect to match the rule
  • 发送到和发送自您的组织中的用户的邮件Messages sent to and from people in your organization
  • 发送到和发送自您的组织外部的用户的邮件Messages sent to and from people outside your organization
  • 对与规则匹配的邮件的答复Replies to messages that match the rule
  • 可能会导致多个规则之间交互的邮件Messages that might cause interactions between multiple rules

发送测试邮件的提示Tips for sending test messages

一种测试方法是以测试邮件的发件人和收件人身份登录。One way to test is to sign in as both the sender and recipient of a test message.

  • 如果你没有对组织中多个帐户的访问权限,可以在试用帐户中进行测试或在组织中创建一些临时的假用户。If you don't have access to multiple accounts in your organization, you can test in a trial account or create a few temporary fake users in your organization.

  • 由于 Web 浏览器通常不允许您在登录到多个帐户的相同计算机上同时打开多个会话,您可以使用 Internet Explorer InPrivate 浏览,或为每个用户使用不同的计算机、设备或 Web 浏览器。Because a web browser typically doesn't let you have simultaneous open sessions on the same computer signed in to multiple accounts, you can use Internet Explorer InPrivate Browsing, or a different computer, device, or web browser for each user.

查看邮件跟踪Look at the message trace

邮件跟踪包括邮件匹配的的每个规则,以及规则采取的每个操作的条目。这对于跟踪测试邮件会发生什么情况非常有用,还可以跟踪实际邮件在您的组织中传递时会发生什么情况。The message trace includes an entry for each rule that is matched for the message, and an entry for each action the rule takes. This is useful for tracking what happens to test messages, and also for tracking what happens to real messages going through your organization.

显示邮件流规则操作的邮件跟踪

  1. 在 EAC 中,转到"邮件 > ""邮件跟踪"。In the EAC, go to Mail flow > Message trace.

  2. 查找您要使用发件人和发送日期等条件跟踪的邮件。若要帮助指定条件,请参阅Run a Message Trace and View ResultsFind the messages that you want to trace by using criteria such as the sender and the date sent. For help specifying criteria, see Run a Message Trace and View Results.

  3. 找到您想要跟踪的邮件后,请双击该邮件以查看有关邮件的详细信息。After locating the message you want to trace, double-click it to view details about the message.

  4. 在“事件”列中查找“传输规则”。“操作”列显示执行的特定操作。Look in the Event column for Transport rule. The Action column shows the specific action taken.

步骤 3:完成测试后,将规则设置为强制Step 3: When you're done testing, set the rule to enforce

  1. In the EAC, go to Mail flow > Rules.In the EAC, go to Mail flow > Rules.

  2. 选择一个规则,然后选择“编辑”。Select a rule, and then select Edit.

  3. 选择“强制实施”。Select Enforce.

  4. 如果您使用某项操作来生成事件报告,请选择操作,然后选择“删除”。If you used an action to generate an incident report, select the action and then select Remove.

  5. 选择“保存”。Select Save.

提示

为避免意外,请向用户介绍新规则。To avoid surprises, inform your users about new rules.

疑难解答建议Troubleshooting suggestions

下面是一些常见的问题和解决方法:Here are some common problems and resolutions:

  • 一切都看上去正常,但规则不起作用。Everything looks right, but the rule isn't working.

    有时可能需要 15 分钟以上的时间,新邮件流才可用。请等待几小时,然后再进行测试。另外,请检查是否另一个规则存在干扰。请尝试将此规则移动到列表顶部,并将其优先级更改为 0。Occasionally it takes longer than 15 minutes for a new mail flow to be available. Wait a few hours, and then test again. Also check to see if another rule might be interfering. Try changing this rule to priority 0 by moving it to the top of the list.

  • 将免责声明添加到原始邮件和所有答复,而不仅仅是原始邮件。Disclaimer is added to original message and all replies, instead of just the original message.

    为避免此问题,可以向免责声明规则添加一种例外,在免责声明中查找某个唯一短语。To avoid this, you can add an exception to your disclaimer rule to look for a unique phrase in the disclaimer.

  • 我的规则具有两个条件,我希望在满足任一条件时即执行操作,但它仅在满足两个条件时才执行操作。My rule has two conditions, and I want the action to happen when either of the conditions is met, but it only is matched when both conditions are met.

    您需要创建两个规则,每个条件一个。您可以通过选择“复制”轻松地复制规则,然后从原始条件和副本中的其他条件删除一个条件。You need to create two rules, one for each condition. You can easily copy the rule by selecting Copy and then remove one condition from the original and the other condition from the copy.

  • 我与通讯组合作, 发件人 ( SentTo) 似乎 不起作用。I'm working with distribution groups, and The sender is ( SentTo) doesn't seem to be working.

    SentTo 匹配其中一个收件人是邮箱、已启用邮件的用户或联系人的邮件,但无法指定具有此条件的通讯组。SentTo matches messages where one of the recipients is a mailbox, mail-enabled user, or contact, but you can't specify a distribution group with this condition. 相反,使用 "To"框包含 SentToMemberOf (组) 。Instead, use To box contains a member of this group ( SentToMemberOf).

其他测试选项Other testing options

如果您正在使用 Exchange Online 或 Exchange Online Protection,您可以通过使用规则报告来检查每一条规则的匹配次数。If you're using Exchange Online or Exchange Online Protection, you can check the number of times each rule is matched by using a rules report. 为了包含在报告中,必须选中规则的“使用以下严重性级别审核此规则”复选框。In order to be included in the reports, a rule must have the Audit this rule with severity level check box selected. 这些报告有助于您揭示规则使用情况中的趋势并标识不匹配的规则。These reports help you spot trends in rule usage and identify rules that are not matched.

若要查看规则报告,请在管理中心Microsoft 365报告 "。To view a rules report, in the Microsoft 365 admin center, select Reports.

备注

虽然大部分数据会在 24 小时内出现在报告中,但有些数据可能需要长达 5 天才会出现。While most data is in the report within 24 hours, some data may take as long as 5 days to appear.

显示规则使用情况的报告

若要了解详细信息,请参阅查看邮件保护报告To learn more, see View mail protection reports.

需要更多帮助吗?Need more help?

管理邮件流规则Manage mail flow rules

Exchange Online 中的邮件流规则(传输规则)Mail flow rules (transport rules) in Exchange Online