Common error
Microsoft 365 may reject outgoing email with an error similar to:
550 5.7.23 The message was rejected because of Sender Policy Framework violation
550 5.7.1 Message rejected: Message lacks SPF/DKIM/DMARC Auth Records
Step 2: Configure the SPF record
If Microsoft 365 is the only service sending email, use:
| Field | Value |
|---|---|
| Type | TXT |
| Host / Name | @ |
| Value | v=spf1 include:spf.protection.outlook.com -all |
| TTL | 1 Hour (3600 seconds) |
TEST :
Run:
nslookup -type=TXT company.com 8.8.8.8
Expected result:
v=spf1 include:spf.protection.outlook.com -all
3. Configure DKIM (DomainKeys Identified Mail)
Navigate to:
https://security.microsoft.com/authentication?viewid=DKIM
Alternatively:
-
Open Microsoft Defender.
-
Expand Email & collaboration.
-
Select Policies & rules.
-
Open Threat policies.
-
Find Email authentication settings.
-
Select the DKIM tab.
Step 2: Select your domain
Choose the domain you want to configure.
Microsoft will display two required CNAME records.
Important: The CNAME targets are generated specifically for your Microsoft 365 tenant and domain. Never copy targets from another domain or tenant.
Step 3: Add the two CNAME records to DNS
Use the exact values provided by Microsoft.
| Field | Selector 1 | Selector 2 |
|---|---|---|
| Type | CNAME | CNAME |
| Host / Name | selector1._domainkey | selector2._domainkey |
| Target | Microsoft-provided value | Microsoft-provided value |
| TTL | 1 Hour | 1 Hour |
TEST
Navigate to:
https://security.microsoft.com/authentication?viewid=DKIM
Alternatively:
-
Open Microsoft Defender.
-
Expand Email & collaboration.
-
Select Policies & rules.
-
Open Threat policies.
-
Find Email authentication settings.
-
Select the DKIM tab.
Step 2: Select your domain
Choose the domain you want to configure.
Microsoft will display two required CNAME records.
Important: The CNAME targets are generated specifically for your Microsoft 365 tenant and domain. Never copy targets from another domain or tenant.
Step 3: Add the two CNAME records to DNS
Use the exact values provided by Microsoft.
| Field | Selector 1 | Selector 2 |
|---|---|---|
| Type | CNAME | CNAME |
| Host / Name | selector1._domainkey | selector2._domainkey |
| Target | Microsoft-provided value | Microsoft-provided value |
| TTL | 1 Hour | 1 Hour |
Example:
Host: selector1._domainkey
Target:
selector1-company-com._domainkey.company.onmicrosoft.com
Host: selector2._domainkey
Target:
selector2-company-com._domainkey.company.onmicrosoft.com
These are examples only. Always use the actual values displayed in your Microsoft 365 tenant.
Step 4: Verify both CNAME records
Run:
nslookup -type=CNAME selector1._domainkey.company.com 8.8.8.8
nslookup -type=CNAME selector2._domainkey.company.com 8.8.8.8
Navigate to:
https://security.microsoft.com/authentication?viewid=DKIM
Alternatively:
-
Open Microsoft Defender.
-
Expand Email & collaboration.
-
Select Policies & rules.
-
Open Threat policies.
-
Find Email authentication settings.
-
Select the DKIM tab.
Step 2: Select your domain
Choose the domain you want to configure.
Microsoft will display two required CNAME records.
Important: The CNAME targets are generated specifically for your Microsoft 365 tenant and domain. Never copy targets from another domain or tenant.
Step 3: Add the two CNAME records to DNS
Use the exact values provided by Microsoft.
| Field | Selector 1 | Selector 2 |
|---|---|---|
| Type | CNAME | CNAME |
| Host / Name | selector1._domainkey | selector2._domainkey |
| Target | Microsoft-provided value | Microsoft-provided value |
| TTL | 1 Hour | 1 Hour |
Example:
Host: selector1._domainkey
Target:
selector1-company-com._domainkey.company.onmicrosoft.com
Host: selector2._domainkey
Target:
selector2-company-com._domainkey.company.onmicrosoft.com
These are examples only. Always use the actual values displayed in your Microsoft 365 tenant.
Step 4: Verify both CNAME records
Run:
nslookup -type=CNAME selector1._domainkey.company.com 8.8.8.8
nslookup -type=CNAME selector2._domainkey.company.com 8.8.8.8
Both commands should return the corresponding Microsoft 365 CNAME targets.
Step 5: Enable DKIM
Return to Microsoft Defender:
https://security.microsoft.com/authentication?viewid=DKIM
-
Select your domain.
-
Confirm that Microsoft recognizes both CNAME records.
-
Enable DKIM signing for the domain.
4. Configure DMARC (Domain-based Message Authentication, Reporting & Conformance)
DMARC tells receiving mail servers how to handle messages that fail authentication and alignment checks.
It also allows domain administrators to receive authentication reports.
Step 1: Check whether DMARC already exists
Run:
nslookup -type=TXT _dmarc.company.com 8.8.8.8
If the record does not exist, create one.
Step 2: Add the DMARC TXT record
For initial monitoring, use:
| Field | Value |
|---|---|
| Type | TXT |
| Host / Name | _dmarc |
| Value | v=DMARC1; p=none; |
| TTL | 1 Hour |
