A label that says "Internal" is a promise. Whether that promise holds when a user types an external address into the To line depends entirely on how Exchange Online transport, Microsoft Purview DLP and, in many Swiss and German organisations, a SEPPmail gateway are configured to work together. Five use cases, from design to PowerShell.
The challenge: classification that stops at the Send button
Level 200Most organisations that roll out Microsoft Purview sensitivity labels start with the visible part: a label bar in Outlook and Office, a few labels such as Public, Internal, Confidential and Strictly Confidential, maybe a header or footer that marks documents. Users are trained, adoption reports look good, and the auditors are pleased that a classification scheme exists.
Then someone asks the obvious question: "What happens if I send an email labelled Internal to an external address?" In many tenants, the honest answer is: it gets delivered. The label is metadata. Unless the label applies encryption, or unless something in the mail flow evaluates that metadata and acts on it, a label is a statement of intent, not a control.
There are three layers that can turn a label into an enforced rule for email:
- The label itself, if it applies Microsoft Purview encryption with permissions that exclude external people. The message is delivered, but the external recipient cannot open it.
- Microsoft Purview DLP for Exchange, which can evaluate the label of the message and of its attachments and block, moderate, redirect or modify the message in transport.
- Exchange Online mail flow rules, which can read the label metadata in the message header and act on it, and which control routing to external systems.
Add a Secure Email Gateway such as SEPPmail, which is widespread in Switzerland and Germany for S/MIME, OpenPGP and its password-based GINA encryption, and the picture gets more interesting. Now the label should not only decide whether a message may leave, but also how it leaves: in clear text, S/MIME-encrypted, or as a GINA message. That requires Exchange Online, Purview and the gateway to agree on a common language, which in practice consists of message headers, connectors and carefully ordered rules.
This article is about exactly that interplay. It is long, because the details matter: a single StopRuleProcessing in the wrong rule is enough to send confidential mail around the gateway in clear text.
A realistic case: a wealth manager with labels and SEPPmail
Level 200 to 300Northwind Vermögensverwaltung AG is a Swiss independent wealth manager with 180 employees, Microsoft 365 E5 and SEPPmail.cloud for secure email with clients, custodian banks and auditors. The MX record points to Exchange Online; SEPPmail.cloud is integrated in parallel mode. Sensitivity labels were introduced a year ago:
| Label | Meaning | Configuration at the start of the project |
|---|---|---|
| Public | Approved for publication | No protection |
| Internal | For employees only | Footer "Internal", no encryption |
| Confidential – Partners | May be shared with contracted partners (custodian banks, auditors, outsourced compliance) | Footer "Confidential", no encryption |
| Confidential – Clients | Client data, must leave only encrypted | Footer "Confidential", no encryption; users were told to type [confidential] in the subject for SEPPmail |
| Strictly Confidential | Board, HR, legal | Purview encryption, members of the organisation only |
A review by the internal control function found the gaps you would expect:
- In a sample of one month, 37 messages labelled Internal had been sent to external recipients, 9 of them with Internal-labelled attachments in otherwise unlabelled messages.
- About one in six client emails labelled "Confidential – Clients" left without encryption, because the sender forgot the subject keyword.
- Some users had discovered that typing
[plain]in the subject prevented SEPPmail from encrypting, which "made it easier for clients". - "Confidential – Partners" messages had been sent to a former auditor's domain long after the mandate ended.
- An old mail flow rule, created during a disclaimer project, had
StopRuleProcessingenabled and sat above the SEPPmail rules. For messages matching it, SEPPmail never saw the mail.
The target state was formulated in five use cases, which also form the structure of the rest of this article:
| # | Use case | Topic |
|---|---|---|
| UC1 | Integrate SEPPmail cleanly in parallel mode: inbound decryption, outbound processing, no bypass by other rules | SEPPmail |
| UC2 | Email or attachment labelled Internal is technically prevented from reaching external recipients | Sensitivity labels |
| UC3 | "Confidential – Partners" may only go to approved partner domains | Sensitivity labels |
| UC4 | "Confidential – Clients" (message or attachment) to external recipients is always encrypted by SEPPmail, without subject keywords | Combined |
| UC5 | Users cannot override enforced encryption with [plain], [noenc] or the corresponding headers | Combined |
Technical foundations
Level 300 to 400Where a label lives in an email
Everything that follows depends on one technical detail: a sensitivity label is stored in different places depending on whether it is applied to the message or to an attached file.
Three consequences follow directly:
- A mail flow rule can reliably detect the label of the message by testing the
msip_labelsheader for the label's GUID. - The label of an attachment is part of the file's metadata. Modern Office versions store that metadata in a format that mail flow rule conditions such as "attachment property contains" cannot reliably evaluate, especially in tenants where co-authoring for labelled files is enabled. Do not build controls for attachment labels on mail flow rules.
- Microsoft Purview DLP for Exchange has a dedicated condition, Content contains › Sensitivity labels, that evaluates the email and its attachments. That is the primary engine for label enforcement in email.
You need the label GUIDs for both engines. They are stable identifiers; display names can change.
PowerShell (Security & Compliance): label names and GUIDs
Connect-IPPSSession
Get-Label | Sort-Object Priority |
Format-Table Priority, DisplayName, Name, Guid, ContentType -AutoSize
Open a labelled test message in Outlook (File › Properties › Internet headers) or use the Microsoft Message Header Analyzer. The msip_labels header contains one block per label with the GUID, the tenant ID (SiteId), the labelling method and the date. The rule conditions in this article look for the substring MSIP_Label_<GUID>_Enabled=true.
DLP or mail flow rule: which engine sees what
Purview DLP for Exchange is not a separate gateway. Its rules run in the Exchange Online transport pipeline, and for Exchange they offer many of the same actions as mail flow rules: block, moderate, redirect, add recipients, set or remove headers, prepend or modify the subject, apply an HTML disclaimer, and apply or remove message encryption. That makes it possible to use DLP not only for blocking, but as a classifier that marks messages for downstream systems, which is exactly what we need for SEPPmail.
| Capability | Purview DLP (Exchange) | Mail flow rule |
|---|---|---|
| Detect label on message | Yes (Content contains › Sensitivity labels) | Yes (header msip_labels) |
| Detect label on attachments | Yes | Not reliably |
| Detect "nothing is labelled" | Yes (Content is not labeled) | Only for the message, by absence of the header |
| Block / NDR to sender | Yes, with policy tip in Outlook before sending | Yes (reject), no policy tip |
| Moderation, redirect, add recipients | Yes | Yes |
| Set or remove headers, modify subject | Yes (SetHeader, RemoveHeader, ModifySubject, PrependSubject) | Yes |
| Route through a specific connector | No | Yes (RouteMessageOutboundConnector) |
| Alerts, incident reports, Activity explorer | Yes | Audit severity and message trace only |
| Recipient conditions bifurcate the message | Yes (internal and external copies handled separately) | Yes |
The design principle Northwind adopted: DLP decides, mail flow rules route. DLP evaluates labels on message and attachments and either blocks or marks the message with a header. Mail flow rules, including the ones SEPPmail installs, handle routing and the gateway control.
How SEPPmail integrates with Exchange Online
SEPPmail is available as an appliance (on-premises or operated by an MSP) and as SEPPmail.cloud. For Exchange Online, SEPPmail provides two PowerShell modules on the PowerShell Gallery that create the required connectors and mail flow rules: SEPPmail365 for the appliance (cmdlets with the prefix SM365) and SEPPmail365cloud for SEPPmail.cloud (prefix SC365). Two routing modes exist:
| Mode | MX points to | Inbound flow | Outbound flow |
|---|---|---|---|
| Inline | SEPPmail | Internet › SEPPmail (filtering, decryption) › Exchange Online | Exchange Online › SEPPmail › Internet |
| Parallel | Exchange Online | Internet › Exchange Online (EOP) › encrypted or signed mail is routed to SEPPmail for decryption and back | Exchange Online › SEPPmail (crypto processing) › back to Exchange Online › Internet |
Parallel mode is the more common choice for organisations that want to keep Exchange Online Protection and Defender for Office 365 as the primary filter. It is also the mode where mail flow rules matter most, because the routing to and from SEPPmail is done entirely by rules and connectors in your tenant.
The SEPPmail.cloud module creates one inbound and one outbound connector and a small set of mail flow rules. According to SEPPmail's documentation for current module versions, the parallel-mode rules include:
| Rule | Direction | Purpose | Customise? |
|---|---|---|---|
| 050 | Inbound | Prevents messages that failed SPF from being routed to SEPPmail | No |
| 060 | Inbound | Sets a rule version header so SEPPmail can detect outdated rule sets | No |
| 100 | Inbound | Routes signed and encrypted inbound messages to SEPPmail for decryption and signature validation; excludes messages already processed and high-SCL messages | Not recommended |
| 110 | Inbound | Removes fake subject tags (for example a forged "[secure]" marker from an external sender) | No |
| 200 | Outbound | Routes outbound messages to SEPPmail for cryptographic processing, except messages carrying the X-SM-outgoing header (already processed) | Yes, for example to limit it to certain senders |
| 300 and higher | Outbound | Remove SEPPmail X-headers before messages leave for the Internet | No |
The exact set and numbering of rules has changed between module versions (SEPPmail reduced the number of parallel-mode rules in recent releases), so always compare with the output of Get-SC365Rules in your tenant rather than with a list in a blog post.
Controlling SEPPmail from Exchange Online
A SEPPmail gateway decides what to do with an outbound message based on its rule set: automatic encryption when a certificate or key for the recipient is known, policies per domain, and explicit triggers from the sender. These explicit triggers are subject keywords and X-headers. The SEPPmail Outlook add-in, for example, sets X-headers; users without the add-in type keywords. The defaults documented by SEPPmail are:
| Subject keyword | Header and value | Effect |
|---|---|---|
[confidential] | x-smenc: yes | Enforce encryption according to the encryption hierarchy (S/MIME, OpenPGP, TLS-based domain encryption or GINA as fallback) |
[priv] | x-smwebmail: yes | Enforce GINA (web-based) encryption |
[sign] | x-smsign: yes | Sign the message |
[plain] | x-smplain: yes | Suppress any cryptographic processing |
[noenc] | x-smnoenc: yes | Suppress encryption when encryption is the default |
Keywords can be customised on the gateway, so check the configuration of your SEPPmail instance. For automation from Exchange Online, headers are the better interface: they are invisible to recipients, do not change the subject line that the user wrote and are easy to set and remove with DLP and mail flow rules. The last two rows are just as important as the first three, because they describe how a user can switch encryption off, which is the topic of use case 5.
Rule order: the part that breaks most setups
DLP rules and mail flow rules are evaluated in the transport pipeline. Within the mail flow rules, priority decides the order, and every matching rule applies unless one of them stops processing. Three facts produce most of the problems I see in SEPPmail tenants:
- The SEPPmail modules place their rules at the bottom of the rule list by default.
- Any rule above them with
StopRuleProcessingenabled prevents the SEPPmail routing rules from being evaluated for the messages it matches. The message then leaves directly, unencrypted. - In parallel mode, an outbound message passes the rules twice: once on the way to SEPPmail, and once when it comes back with the
X-SM-outgoingheader. Rules that modify messages (disclaimers, subject tags) must account for that, or they apply twice or modify a message that has already been signed.
PowerShell: find rules that can bypass SEPPmail
Connect-ExchangeOnline
$rules = Get-TransportRule | Sort-Object Priority
$sepp = $rules | Where-Object Name -like "*SEPPmail*" | Select-Object -First 1
$rules | Where-Object {
$_.Priority -lt $sepp.Priority -and $_.StopRuleProcessing -and
-not ($_.RejectMessageReasonText -or $_.DeleteMessage)
} | Format-Table Priority, Name, State, StopRuleProcessing
Every rule this returns stops processing above the SEPPmail rules without ending the message's journey. Each one is a potential path around the gateway and needs to be either reordered below the SEPPmail rules, or have StopRuleProcessing removed.
Use case 1: SEPPmail in parallel mode
Level 300 to 400Goal: MX stays at Microsoft, so Exchange Online Protection and Defender for Office 365 filter all inbound mail first. Encrypted and signed inbound messages are decrypted and validated by SEPPmail.cloud. All outbound messages pass SEPPmail, which encrypts or signs according to its rule set and the triggers set in Exchange Online. No other rule may route messages around the gateway.
Step 1: prepare
- All mailboxes are in Exchange Online, and the SEPPmail.cloud tenant with the managed domains has been provisioned by SEPPmail or your partner.
- If the tenant was previously integrated with a SEPPmail appliance, remove those connectors and rules first (module
SEPPmail365, cmdletsRemove-SM365RulesandRemove-SM365Connectors). - Export the current rule collection and run the bypass check from the previous section.
PowerShell 7: install the module and back up the current state
Install-Module SEPPmail365cloud -Scope CurrentUser
Install-Module ExchangeOnlineManagement -Scope CurrentUser
Connect-ExchangeOnline -UserPrincipalName admin@northwind.ch
# Backup of all mail flow rules before any change
$export = Export-TransportRuleCollection
[System.IO.File]::WriteAllBytes("C:\Backup\ETR-before-SEPPmail.xml", $export.FileData)
Get-InboundConnector | Format-Table Name, Enabled, ConnectorType
Get-OutboundConnector | Format-Table Name, Enabled, IsTransportRuleScoped
Step 2: create connectors and rules
The module creates the connectors for your SEPPmail.cloud region and the routing mode. Rules can only be created when the connectors exist and are enabled. For a controlled go-live, create both in disabled state and enable them in a maintenance window.
PowerShell 7: SEPPmail.cloud parallel mode
# Region according to your SEPPmail.cloud contract
New-SC365Connectors -SEPPmailCloudDomain "northwind.ch" -routing "parallel" -region "<region>" -disabled
New-SC365Rules -SEPPmailCloudDomain "northwind.ch" -routing "parallel" -disabled
# Review what was created
Get-SC365Connectors -routing "parallel"
Get-SC365Rules -routing "parallel"
# Go-live: enable connectors first, then the rules
Get-InboundConnector | Where-Object Name -like "*SEPPmail*" | Set-InboundConnector -Enabled $true
Get-OutboundConnector | Where-Object Name -like "*SEPPmail*" | Set-OutboundConnector -Enabled $true
Get-TransportRule | Where-Object Name -like "*SEPPmail*" | Enable-TransportRule
- [SEPPmail.cloud] Outbound-Parallel
- From Office 365 to Partner organizationUsed only when a mail flow rule redirects messages (rule-scoped), TLS to SEPPmail.cloud
- [SEPPmail.cloud] Inbound-Parallel
- From Partner organization to Office 365Accepts messages returning from SEPPmail.cloud, identified by its TLS certificate
Step 3: adjust your own rules to the second pass
Because outbound messages return from SEPPmail and are evaluated again, every rule that modifies outbound messages needs an exception for already processed messages. The SEPPmail routing rule itself uses the header X-SM-outgoing with the value yes for this purpose; use the same marker in your rules.
PowerShell: disclaimer only on the first pass
Set-TransportRule -Identity "DISCLAIMER | Legal footer | External" `
-ExceptIfHeaderContainsMessageHeader "X-SM-outgoing" `
-ExceptIfHeaderContainsWords "yes"
This keeps the disclaimer on the first pass, before SEPPmail signs or encrypts the message. Adding text after SEPPmail has signed a message would break the signature.
Step 4: verify
- Send a test message to an external mailbox and check the received headers: the path should show SEPPmail.cloud between the two Exchange Online hops, and no
X-SM-*control headers should reach the recipient. - Send an S/MIME-encrypted message from a partner with a known certificate: it should arrive decrypted and marked by SEPPmail.
- Check the DKIM signature and DMARC result at an external recipient after the round trip through SEPPmail.
- Run the bypass check again.
First, if Exchange Online rewrites the recipient address before the SEPPmail rules run (for example after a change of the primary domain), SEPPmail cannot find the private key for decryption, according to SEPPmail's documentation. Second, if you enabled RejectDirectSend, make sure messages returning from SEPPmail are attributed to the partner inbound connector (certificate-based), so they are not treated as unauthenticated Direct Send.
Rule 200 can be customised, for example to send only members of a group through SEPPmail. Northwind left it unchanged: every external message passes the gateway, and SEPPmail decides based on triggers and recipient keys whether to encrypt. The decisive control in this design is not "which messages go to SEPPmail", but "which messages arrive at SEPPmail with which instruction". That is what use cases 4 and 5 deliver.
Use case 2: "Internal" never leaves the organisation
Level 300 to 400Requirement: if the email or any attachment carries the label Internal (or one of its sublabels), the message must not be delivered to any recipient outside the organisation. Internal recipients of the same message still receive it. The sender is warned in Outlook before sending and gets a clear non-delivery report if they send anyway. Compliance receives an incident report.
Design decisions
| Option | Effect | Northwind's decision |
|---|---|---|
| Label Internal applies Purview encryption (all users in the organisation) | Leaked content cannot be opened externally; but also affects mobile apps, third-party tools and SEPPmail content inspection | Not used for Internal; reserved for Strictly Confidential |
| DLP block in transport (message + attachments) | Technical prevention of delivery to external recipients | Primary control |
Mail flow rule on msip_labels | Second layer for the message label; independent of DLP policy state | Added as defence in depth |
| Label policy: justification for removing or downgrading labels | Users cannot silently relabel Internal to Public to get around the block | Enabled |
Step 1: the DLP policy
Northwind created one Exchange-only DLP policy for all label enforcement rules, with one rule per label. Exchange-only policies offer the full set of Exchange conditions and actions; mixing locations restricts the available options.
- Location
- Exchange email onlyAll users and groups
- Conditions
- Content contains › Sensitivity labels: Internal (incl. sublabels)AND Content is shared from Microsoft 365 › with people outside my organization
- Action
- Restrict access or encrypt the content › Block users from receiving emailBlock everyone (applies to the external copy of the bifurcated message)
- User notifications
- OnPolicy tip: "Internal content cannot be sent outside Northwind."
- User overrides
- Off
- Incident reports
- compliance@northwind.ch, severity High
- If there's a match for this rule, stop applying more DLP policies and rules
- On
PowerShell (Security & Compliance): policy and rule
Connect-IPPSSession
$internal = (Get-Label | Where-Object DisplayName -eq "Internal").Guid
New-DlpCompliancePolicy -Name "LBL | Email label enforcement" `
-ExchangeLocation All `
-Mode TestWithNotifications `
-Comment "Label enforcement for email. Owner: Compliance."
New-DlpComplianceRule -Name "LBL | Internal | Block external" `
-Policy "LBL | Email label enforcement" `
-ContentContainsSensitiveInformation @{
operator = "And"
groups = @(@{
operator = "Or"
name = "Labels"
labels = @(@{ name = "$internal"; type = "Sensitivity" })
})
} `
-AccessScope NotInOrganization `
-BlockAccess $true `
-BlockAccessScope All `
-NotifyUser Owner `
-NotifyPolicyTipCustomText "Internal content cannot be sent outside Northwind. Remove external recipients or ask Compliance." `
-NotifyEmailCustomText "Your message was not delivered to external recipients because it or an attachment is labelled Internal." `
-GenerateIncidentReport "compliance@northwind.ch" `
-IncidentReportContent All `
-ReportSeverityLevel High `
-StopPolicyProcessing $true
The policy starts in TestWithNotifications mode: users already see the policy tip, nothing is blocked, and matches appear in Activity explorer. After a week of reviewing matches, switch it on:
Set-DlpCompliancePolicy -Identity "LBL | Email label enforcement" -Mode Enable
If Internal has sublabels, add each sublabel GUID to the labels array, or select the parent label in the portal, where sublabels are included in the selection. Label metadata stays readable even when a label applies encryption, so the condition also matches encrypted attachments.
Step 2: a mail flow rule as second layer
The DLP rule covers message and attachments. A mail flow rule on the message header adds a second, independent layer for the message label, and it keeps working if someone sets the DLP policy back to test mode during troubleshooting.
PowerShell: reject Internal-labelled messages to external recipients
$internal = "<GUID of Internal>"
New-TransportRule -Name "LBL | Internal | Reject external (header)" `
-FromScope InOrganization `
-SentToScope NotInOrganization `
-HeaderContainsMessageHeader "msip_labels" `
-HeaderContainsWords "MSIP_Label_$($internal)_Enabled=true" `
-RejectMessageReasonText "This message is labelled Internal and cannot be sent outside Northwind." `
-RejectMessageEnhancedStatusCode "5.7.1" `
-SetAuditSeverity High `
-StopRuleProcessing $true `
-Priority 0 `
-Mode Audit `
-Comments "UC2 | Second layer to DLP | Owner: Compliance"
This rule may stop processing: it rejects the external copy, so nothing further needs to happen with it. It sits at priority 0, above everything else, including the SEPPmail rules.
Step 3: close the downgrade path
The cleanest technical block is useless if a user can simply change Internal to Public before sending. In the label policy, enable "Users must provide a justification to remove a label or lower its classification". The justification is recorded in the audit log, and the DLP incident reports together with these audit events give Compliance a complete picture. For E5 tenants, DLP oversharing pop-ups in Outlook for Windows add a pre-send dialog that lists the external recipients and the matched label, which reduces the number of NDRs considerably.
Use case 3: "Confidential – Partners" only to approved partners
Level 300 to 400Requirement: messages or attachments labelled "Confidential – Partners" may be sent internally and to the domains of contracted partners (two custodian banks, the audit firm, the outsourced compliance provider). Sending to any other external domain is blocked. When a contract ends, removing the partner from one list must be enough.
The key is to maintain the allowed domains in one place. Northwind used the DLP rule's recipient domain exception, maintained by a small script that reads the partner register:
PowerShell (Security & Compliance): partner-restricted label
$partnerLabel = (Get-Label | Where-Object DisplayName -eq "Confidential – Partners").Guid
$partnerDomains = Get-Content "C:\Config\approved-partner-domains.txt" # one domain per line
New-DlpComplianceRule -Name "LBL | Confidential-Partners | Block non-partners" `
-Policy "LBL | Email label enforcement" `
-ContentContainsSensitiveInformation @{
operator = "And"
groups = @(@{
operator = "Or"; name = "Labels"
labels = @(@{ name = "$partnerLabel"; type = "Sensitivity" })
})
} `
-AccessScope NotInOrganization `
-ExceptIfRecipientDomainIs $partnerDomains `
-BlockAccess $true `
-BlockAccessScope All `
-NotifyUser Owner `
-NotifyPolicyTipCustomText "This content may only be shared with approved partners. At least one recipient is not on the partner list." `
-GenerateIncidentReport "compliance@northwind.ch" -IncidentReportContent All `
-ReportSeverityLevel Medium
# When the partner list changes
Set-DlpComplianceRule -Identity "LBL | Confidential-Partners | Block non-partners" `
-ExceptIfRecipientDomainIs (Get-Content "C:\Config\approved-partner-domains.txt")
Two refinements made the rule practical:
- Subdomains: "Recipient domain is" matches exact domains. If a partner uses several subdomains, list them, or use a recipient address pattern exception (
ExceptIfAnyOfRecipientAddressMatchesPatterns) with an anchored regex such as@([a-z0-9-]+\.)?custodian-bank\.example$. Pattern conditions do not bifurcate, so test that variant carefully with mixed recipients. - Encryption on the way out: partners receive "Confidential – Partners" content through SEPPmail, encrypted with S/MIME where certificates are exchanged, or via TLS-based domain encryption agreed with the banks. That is configured on the gateway, not in Exchange Online.
Use case 4: label-driven encryption through SEPPmail
Level 400Requirement: every message to an external recipient that is labelled "Confidential – Clients", or that contains an attachment with this label, is encrypted by SEPPmail. Users do not type any subject keyword. Internal copies stay unencrypted. Clients without certificates receive a GINA message, clients and banks with exchanged certificates receive S/MIME.
This is where the principle "DLP decides, mail flow rules route" pays off. Purview DLP sees labels on the message and on attachments, and it can set a header. The SEPPmail routing rule sends all outbound mail to the gateway anyway. The only missing link is an instruction the gateway understands: x-smenc: yes.
Step 1: label configuration
"Confidential – Clients" must not apply Microsoft Purview encryption. If it did, the message would already be protected with Microsoft's rights management when it reaches SEPPmail; the gateway could still wrap it in S/MIME or GINA, but the client would then need to deal with two protection layers and a Microsoft identity. Decide per label which technology encrypts. At Northwind: SEPPmail for clients and partners, Purview encryption only for Strictly Confidential, which never leaves the organisation.
- Scope
- Files & other data assets, Emails
- Access control (encryption)
- OffEncryption for external delivery is done by SEPPmail
- Content marking
- Footer "Confidential – Clients"
- Label policy
- Justification required to remove or downgrade
Step 2: the DLP rule that instructs the gateway
- Conditions
- Content contains › Sensitivity labels: Confidential – ClientsAND Content is shared with people outside my organization
- Exceptions
- Header contains words: X-SM-outgoing = yesMessage already processed by SEPPmail (second pass)
- Actions
- Set header: x-smenc = yes
- Block
- OffThe message is delivered, encrypted
- Incident report
- OffNormal business flow, no incident
PowerShell (Security & Compliance): set the encryption header for labelled content
$clients = (Get-Label | Where-Object DisplayName -eq "Confidential – Clients").Guid
New-DlpComplianceRule -Name "LBL | Confidential-Clients | Encrypt via SEPPmail" `
-Policy "LBL | Email label enforcement" `
-ContentContainsSensitiveInformation @{
operator = "And"
groups = @(@{
operator = "Or"; name = "Labels"
labels = @(@{ name = "$clients"; type = "Sensitivity" })
})
} `
-AccessScope NotInOrganization `
-SetHeader "x-smenc:yes" `
-ExceptIfHeaderContainsWords @{ "X-SM-outgoing" = "yes" } `
-Comment "UC4 | Instructs SEPPmail to encrypt | Owner: Messaging"
The Purview reference documents SetHeader with the syntax "HeaderName:HeaderValue" and the header conditions as hash tables. If your version of the Security & Compliance module expects a different format, configure the action in the portal ("Set header") and use Get-DlpComplianceRule | Format-List SetHeader, ExceptIfHeaderContainsWords to see how it is stored.
Step 3: a mail flow rule as fallback for the message label
For the message label, a mail flow rule can set the same header. Northwind added it so that encryption of labelled messages does not depend on a single engine. It must be placed above the SEPPmail rules and must not stop rule processing, otherwise rule 200 never routes the message to the gateway.
PowerShell: header-based fallback
$clients = "<GUID of Confidential – Clients>"
New-TransportRule -Name "LBL | Confidential-Clients | Mark for SEPPmail (header)" `
-FromScope InOrganization `
-SentToScope NotInOrganization `
-HeaderContainsMessageHeader "msip_labels" `
-HeaderContainsWords "MSIP_Label_$($clients)_Enabled=true" `
-ExceptIfHeaderContainsMessageHeader "X-SM-outgoing" `
-ExceptIfHeaderContainsWords "yes" `
-SetHeaderName "x-smenc" -SetHeaderValue "yes" `
-StopRuleProcessing $false `
-Priority 2 `
-Mode Enforce `
-Comments "UC4 | Fallback for message label | Must stay above SEPPmail rules"
Both rules setting the same header is harmless; the gateway only needs the instruction once. In the received message at the external test mailbox, verify that the control header does not reach the recipient. If it does in your configuration, add a cleanup rule that removes x-smenc from external messages that already carry X-SM-outgoing: yes.
Why not simply route labelled mail through a dedicated connector?
In parallel mode, all outbound mail already passes SEPPmail through rule 200. A second connector or routing rule for labelled mail would duplicate that path and create another way to get the order wrong. Marking the message and letting the existing path carry it is simpler and easier to troubleshoot.
Use case 5: users cannot switch off enforced encryption
Level 400Requirement: for content labelled "Confidential – Clients", the gateway's opt-out triggers must not work. A user typing [plain] or [noenc] into the subject, or an add-in setting x-smplain or x-smnoenc, must not lead to an unencrypted message. Attempts are logged.
Use case 4 adds an instruction to encrypt. Use case 5 removes the instructions not to. Without it, the gateway receives conflicting signals, and how it resolves them depends on its rule set. Removing the conflict in Exchange Online makes the outcome deterministic.
Configuration
Extend the use case 4 rule with two actions, or create a separate rule in the same policy if you want separate reporting for override attempts. Northwind used a separate rule, because the incident report for attempted overrides goes to Compliance, while the encryption marking is silent.
- Conditions
- Content contains › Sensitivity labels: Confidential – ClientsAND shared with people outside my organization
- Condition group (any of)
- Subject matches patterns
\[(plain|noenc)\]OR header x-smplain contains "yes" OR header x-smnoenc contains "yes" - Exceptions
- Header X-SM-outgoing contains "yes"
- Actions
- Modify email subject: replace matches of
\[(plain|noenc)\]Remove header: x-smplain, x-smnoenc; Set header: x-smenc = yes - Incident report
- compliance@northwind.ch, severity Low"Attempted encryption opt-out on client data"
In the portal, the condition group uses "Any of these" between the subject pattern and the two header conditions, nested inside an "And" with the label and recipient conditions. In PowerShell, the same logic is easiest to express as two rules (one for the subject pattern, one per header), because each rule's conditions are combined with AND. The relevant parameters of New-DlpComplianceRule are SubjectMatchesPatterns, HeaderContainsWords, ModifySubject, RemoveHeader and SetHeader.
PowerShell (Security & Compliance): header-based opt-out removal
foreach ($h in "x-smplain","x-smnoenc") {
New-DlpComplianceRule -Name "LBL | Confidential-Clients | Remove $h" `
-Policy "LBL | Email label enforcement" `
-ContentContainsSensitiveInformation @{
operator = "And"
groups = @(@{ operator = "Or"; name = "Labels"
labels = @(@{ name = "$clients"; type = "Sensitivity" }) })
} `
-AccessScope NotInOrganization `
-HeaderContainsWords @{ $h = "yes" } `
-ExceptIfHeaderContainsWords @{ "X-SM-outgoing" = "yes" } `
-RemoveHeader $h `
-SetHeader "x-smenc:yes" `
-GenerateIncidentReport "compliance@northwind.ch" -IncidentReportContent All `
-ReportSeverityLevel Low
}
For the subject keywords, configure "Modify email subject" in the portal: pattern \[(plain|noenc)\], replace strategy "Replace", replacement text according to your preference (an empty replacement or a neutral marker). Test how your SEPPmail instance treats subject keywords after encryption; the gateway can be configured to remove its own trigger keywords before delivery.
The SEPPmail rule set itself can restrict who may use opt-out keywords. Exchange Online normalisation makes the common case deterministic; gateway-side restrictions catch everything that does not carry a label, for example unlabelled messages with client data, which you would address separately with a sensitive information type based DLP rule.
Testing, troubleshooting and operations
Level 300 to 400Northwind tested every use case with a fixed matrix of test messages before switching DLP to Enable and mail flow rules to Enforce. The matrix is worth keeping as a regression test for every change to labels, DLP or SEPPmail.
| # | Test message | Recipients | Expected result |
|---|---|---|---|
| T1 | Message labelled Internal | internal + external | Internal delivered; external NDR 5.7.1; incident report |
| T2 | Unlabelled message, attachment labelled Internal | external | NDR; incident report names the attachment |
| T3 | Confidential – Partners | approved bank + gmail.com | Bank delivered (via SEPPmail); gmail NDR |
| T4 | Confidential – Clients, no keyword | client without certificate | GINA message delivered |
| T5 | Confidential – Clients | bank with S/MIME certificate | S/MIME-encrypted message delivered |
| T6 | Confidential – Clients, subject "[plain] …" | external | Encrypted anyway; subject cleaned; low-severity incident |
| T7 | Public, no keyword | external | Delivered according to gateway defaults; no DLP match |
| T8 | Encrypted S/MIME message from a partner | internal | Decrypted by SEPPmail, delivered |
| T9 | Any external message | external | Disclaimer exactly once; no X-SM or x-sm control headers at recipient |
Where to look
- DLP matches: Microsoft Purview › Data loss prevention › Activity explorer and Alerts. Every match shows the rule, the matched label and, for attachments, the file name.
- Mail flow rules and routing: message trace details in Exchange Online. They show which mail flow rules matched and that the message was sent to the SEPPmail connector and received back through the inbound connector.
- Gateway processing: the SEPPmail log shows which trigger caused encryption and which technology was used.
PowerShell: trace a test message through rules and connectors
$m = Get-MessageTraceV2 -SenderAddress "tester@northwind.ch" -RecipientAddress "test@client.example" `
-StartDate (Get-Date).AddHours(-2) -EndDate (Get-Date) | Select-Object -First 1
Get-MessageTraceDetailV2 -MessageTraceId $m.MessageTraceId -RecipientAddress $m.RecipientAddress |
Select-Object Date, Event, Action, Detail | Format-List
# DLP rule configuration as stored
Get-DlpComplianceRule -Policy "LBL | Email label enforcement" |
Format-Table Name, Disabled, BlockAccess, SetHeader, RemoveHeader -AutoSize
Operational rules
- Changing labels: a new sublabel under Internal is not covered until its GUID is added to the rules (or the parent is selected in the portal). Make "update DLP and header rules" part of the label change procedure.
- Updating the SEPPmail module: new module versions can recreate rules and place them at the bottom again. Re-run the bypass check after every update.
- Partner list: the approved domains for "Confidential – Partners" come from the contract register, not from emails to the IT department.
- Exceptions: do not grant user overrides on the Internal rule. If the business needs an exception, it needs a different label.
Why this matters
Level 200 to 300A classification scheme without enforcement creates false confidence. Users believe that a label protects the content, management believes that the classification policy is implemented, and auditors see labels in the reports. The first misaddressed email with an Internal attachment shows that none of this was true. Enforcement in transport turns the label into what everyone already assumes it is.
Attachments are where the data is. In Northwind's sample, a quarter of the Internal leaks were labelled attachments in unlabelled messages. Any design that only looks at the message header misses exactly the content that matters most. Purview DLP's ability to evaluate attachment labels is the reason it has to be part of the solution.
Gateways and Microsoft 365 must speak the same language. SEPPmail and comparable gateways are excellent at encryption for recipients outside the Microsoft ecosystem, which is still the majority of clients for a Swiss bank, wealth manager, law firm or doctor. But they act on instructions. Translating a Purview label into a gateway instruction, and removing contradictory instructions, is what makes the combination reliable and independent of whether a user remembered a keyword.
Regulation expects technical measures, not intentions. The revFADP requires appropriate technical and organisational measures for data security, the GDPR asks for the same under Article 32, and Swiss professional secrecy rules for banks, asset managers, lawyers and healthcare providers make unencrypted client communication a real liability. "Users are trained to type [confidential]" does not survive a serious audit. "Client-labelled content is encrypted automatically and override attempts are logged" does.
Rule order is a security control. The most dangerous configuration in this article is not a missing rule but a misplaced one: a single rule with StopRuleProcessing above the gateway routing silently sends mail around encryption. Treat the order of your mail flow rules with the same care as firewall rules, and check it after every change.
Checklist
- SEPPmail integrated with the official module; connectors and rules match the current module version.
- No rule above the SEPPmail rules uses
StopRuleProcessingunless it rejects or deletes the message. - Message-modifying rules have an exception for
X-SM-outgoing: yes. - Label GUIDs documented; each label's encryption technology decided (Purview or gateway, not both).
- Exchange-only DLP policy for label enforcement, one rule per label, started in test mode.
- Internal: blocked for external recipients, message and attachments; header rule as second layer.
- Partner label: allowed domains maintained from the contract register.
- Client label: DLP sets
x-smenc: yes; header rule as fallback without stopping processing. - Opt-out keywords and headers removed for labelled content; attempts reported.
- Label policy requires justification for removal or downgrade.
- Regression test matrix executed after every change to labels, DLP, mail flow rules or the SEPPmail module.
