Back to blog
Office 3657 min read

How to Configure DKIM and SPF for Office 365 Email: A Step-by-Step Guide

SC

Sarah Chen

IT Security & Infrastructure Lead · September 5, 2026

<h1>How to Configure DKIM and SPF for Office 365 Email</h1> <p>Are your Office 365 emails landing in spam folders or, worse, being rejected by recipients? If so, you're not alone. Many organizations struggle with email deliverability because they haven't properly configured email authentication protocols like SPF and DKIM. Without these, your domain is vulnerable to spoofing and phishing attacks, and your legitimate messages may never reach the inbox.</p> <p>In this guide, we'll walk you through the exact steps to configure SPF and DKIM for Office 365. By the end, you'll have a robust email authentication setup that protects your brand and ensures your messages are trusted by email providers. Whether you're an IT decision maker, business owner, or office manager, this guide is designed to be clear and actionable.</p> <h2>What are SPF and DKIM and Why Do You Need Them?</h2> <p>SPF (Sender Policy Framework) and DKIM (DomainKeys Identified Mail) are two essential email authentication methods that verify your emails are legitimate and not forged. They work by adding DNS records to your domain that tell receiving email servers which servers are authorized to send email on behalf of your domain.</p> <p><strong>SPF</strong> specifies which IP addresses or hostnames are allowed to send email for your domain. It helps prevent spammers from sending emails that appear to come from your domain. <strong>DKIM</strong> adds a digital signature to your outgoing emails, which receiving servers can validate against a public key published in your DNS. This ensures the email hasn't been tampered with during transit and confirms it originated from your domain.</p> <p>Without these protocols, your emails are more likely to be flagged as spam, and your domain is an easy target for cybercriminals. Configuring them isn't just a best practice—it's essential for maintaining trust and deliverability.</p> <h2>Prerequisites: What You Need Before You Start</h2> <p>Before you dive into configuration, ensure you have the following:</p> <ul> <li>Administrator access to your Office 365 tenant (global admin or exchange admin).</li> <li>Access to your domain's DNS management panel (e.g., GoDaddy, Cloudflare, or your hosting provider).</li> <li>Your domain already added and verified in Office 365.</li> </ul> <p>If you're using a third-party email service in addition to Office 365, you'll need to include those servers in your SPF record as well.</p> <h2>Step-by-Step: Configuring SPF for Office 365</h2> <p>Configuring SPF involves adding a TXT record to your DNS. Here's how to do it correctly:</p> <h3>Step 1: Understand the SPF Syntax for Office 365</h3> <p>The standard SPF record for Office 365 is:</p> <pre><code>v=spf1 include:spf.protection.outlook.com -all</code></pre> <p>This record tells receiving servers to allow emails from Microsoft's servers (spf.protection.outlook.com) and to fail emails from any other source. However, if you use other email services (like a marketing platform or on-premises server), you need to include them.</p> <h3>Step 2: Check Your Current SPF Record</h3> <p>First, check if you already have an SPF record. Use a DNS lookup tool or run this command in Command Prompt: <code>nslookup -type=TXT yourdomain.com</code>. Look for a line starting with "v=spf1".</p> <h3>Step 3: Modify or Create Your SPF Record</h3> <p>If you don't have an SPF record, create a new TXT record with the standard Office 365 value. If you have one, you need to add <code>include:spf.protection.outlook.com</code> to it. For example, if your current record is <code>v=spf1 include:sendgrid.net -all</code>, you would change it to <code>v=spf1 include:sendgrid.net include:spf.protection.outlook.com -all</code>.</p> <p>Important: You can only have one SPF record for your domain. If you have multiple, combine them into one.</p> <h3>Step 4: Choose the Right Qualifier</h3> <p>SPF records end with a qualifier that tells receiving servers what to do with emails that fail the check. Common options are <code>-all</code> (hard fail) and <code>~all</code> (soft fail). Microsoft recommends using <code>-all</code> for stricter security, but if you're unsure about all your email sources, you can use <code>~all</code> temporarily.</p> <h3>Step 5: Add the Record in Your DNS Provider</h3> <p>Log in to your DNS provider and navigate to the DNS management page. Create a new TXT record with the host as <code>@</code> (or leave it blank, depending on provider) and the value as your SPF record. Save the record.</p> <h3>Step 6: Verify Your SPF Record</h3> <p>After DNS propagation (which can take up to 48 hours), test your SPF record using a tool like MXToolbox or by sending an email to a service like Gmail and checking the headers.</p> <h2>Step-by-Step: Configuring DKIM for Office 365</h2> <p>Office 365 supports DKIM signing for emails sent from your domain. Here's how to enable it:</p> <h3>Step 1: Understand DKIM in Office 365</h3> <p>Microsoft provides a default DKIM signing for your initial domain (e.g., yourdomain.onmicrosoft.com), but for your custom domain, you need to enable it and create two CNAME records.</p> <h3>Step 2: Generate the DKIM CNAME Records</h3> <p>First, you need to generate two CNAME records that Microsoft will use to publish your DKIM public key. To do this, you can use Exchange Online PowerShell or the Microsoft 365 admin center. Here's a PowerShell method:</p> <ol> <li>Connect to Exchange Online PowerShell (see Microsoft's instructions).</li> <li>Run the following command to get the DKIM records for your domain: <code>Get-DkimSigningConfig -Identity yourdomain.com | Format-List</code>. This will show you the two CNAME records you need to create.</li> </ol> <p>Alternatively, in the Microsoft 365 admin center, go to Admin &gt; Exchange &gt; Protection &gt; dkim. Select your domain and click "Create DKIM keys". Microsoft will display the two CNAME records.</p> <h3>Step 3: Add the CNAME Records to DNS</h3> <p>Log in to your DNS provider and create two CNAME records with the host and target values provided by Microsoft. Typically, they look like:</p> <ul> <li><strong>Host:</strong> selector1._domainkey.yourdomain.com <strong>Value:</strong> selector1-yourdomain-com._domainkey.yourdomain.onmicrosoft.com</li> <li><strong>Host:</strong> selector2._domainkey.yourdomain.com <strong>Value:</strong> selector2-yourdomain-com._domainkey.yourdomain.onmicrosoft.com</li> </ul> <p>Make sure to replace "yourdomain.com" with your actual domain.</p> <h3>Step 4: Enable DKIM Signing in Office 365</h3> <p>Once the CNAME records are propagated (check with a DNS lookup), go back to Exchange admin center &gt; Protection &gt; dkim. Select your domain and click "Enable" under the DKIM section. This will start signing your outgoing emails with DKIM.</p> <h3>Step 5: Verify DKIM Configuration</h3> <p>After enabling, you can verify DKIM is working by sending a test email to a service like Gmail and viewing the full headers. Look for a line like "DKIM-Signature" and check that it passes authentication.</p> <h2>Common Mistakes and Troubleshooting Tips</h2> <p>Even with careful configuration, issues can arise. Here are common pitfalls and how to fix them:</p> <ul> <li><strong>Multiple SPF records:</strong> If you accidentally have more than one SPF record, combine them into a single record. Multiple records cause SPF failures.</li> <li><strong>Exceeding the 10-lookup limit:</strong> SPF records have a limit of 10 DNS lookups. If you include too many services, you'll exceed this limit. Use subdomains or consolidate services.</li> <li><strong>Incorrect CNAME values:</strong> Double-check that you copied the host and target exactly, including the selector numbers.</li> <li><strong>DNS propagation delay:</strong> Changes may take up to 48 hours to take effect. Be patient and retest after that period.</li> <li><strong>Using the wrong domain:</strong> Ensure you're configuring DKIM for the domain you actually send from, not your onmicrosoft.com domain.</li> </ul> <p>If you're still having issues, use tools like MXToolbox's SPF and DKIM checkers to identify problems.</p> <h2>How to Test Your Email Authentication</h2> <p>After configuration, it's crucial to test that everything works. Here are two easy methods:</p> <h3>Method 1: Send a Test Email to a Gmail Address</h3> <p>Send an email from your domain to a Gmail address. Open the email in Gmail, click the three dots next to the reply button, and select "Show original". Look for the authentication results section. You should see <code>SPF: PASS</code> and <code>DKIM: PASS</code>.</p> <h3>Method 2: Use an Online Email Testing Tool</h3> <p>Tools like Mail-Tester.com or GlockApps can analyze your email and provide a detailed report on SPF, DKIM, and DMARC. Simply send an email to the address they provide and check the score.</p> <h2>Next Steps: DMARC and Why You Should Consider It</h2> <p>Once SPF and DKIM are configured, the next step is to set up DMARC (Domain-based Message Authentication, Reporting, and Conformance). DMARC tells receiving servers what to do if both SPF and DKIM fail, and it gives you reports on email authentication activity for your domain. It's the final piece of the email authentication puzzle.</p> <p>To set up DMARC, create a TXT record with a policy like <code>v=DMARC1; p=quarantine; rua=mailto:you@yourdomain.com</code>. Start with p=none to monitor, then tighten over time.</p> <h2>Get Expert Help with Your Office 365 Setup</h2> <p>Configuring SPF and DKIM can be time-consuming, especially if you have a complex email environment. If you'd rather have a professional handle it, consider hiring a vetted IT expert from OnTechCare.com. OnTechCare is a platform where you can find pre-screened remote IT support specialists who can assist with Office 365 configuration, email security, and more.</p> <p>By delegating this task to an expert, you can ensure your email authentication is set up correctly the first time, saving you hours of troubleshooting and potential email deliverability issues.</p> <h2>Conclusion</h2> <p>Properly configuring SPF and DKIM for Office 365 is essential for email deliverability and security. With this guide, you now have the knowledge to set them up yourself. Remember to test your configuration and consider adding DMARC for comprehensive protection.</p> <p>If you encounter any challenges or simply prefer to focus on your core business, don't hesitate to reach out to OnTechCare.com and post a job for a remote IT professional who can handle the technical details for you. Your emails—and your reputation—will thank you.</p>

About the author

SC

Sarah Chen

IT Security & Infrastructure Lead, OnTechCare

Sarah spent eight years in enterprise IT before going independent. She specializes in Active Directory, endpoint security, and keeping small businesses from becoming ransomware statistics. She joined OnTechCare's network in 2024 and works with clients who need serious IT without the enterprise price tag.

Need IT help right now?

Post a job on OnTechCare and get bids from vetted remote IT technicians — usually within hours.

Post a Job Free