Short answer
Take the MX, SPF and DKIM values from Microsoft 365 or Google Workspace and add them at your authoritative DNS; leave the website’s A record alone and set cPanel’s Email Routing to Remote. Send the contact form through the provider’s authenticated SMTP; new Microsoft 365 tenants can reject mail from the hosting server.
1. Separate what each record controls
In this set-up, each job has its own DNS record: the A record (and AAAA, if present) takes visitors to the hosting server, the MX record names the provider that incoming mail is delivered to, and SPF, DKIM and DMARC define who may send on behalf of your domain and how those messages are verified. The contact form is a separate sender: its messages leave from the server running the website or from the SMTP service it connects to, not from a mailbox.
Before you change anything, find the domain’s authoritative name servers (NS); the Whois / RDAP tool gives you the ICANN lookup for generic extensions and the TRABİS lookup for .tr domains. If the NS records point to the hosting name servers listed in your service instructions, you edit the records in cPanel’s Zone Editor; if they point to the registrar or a service such as Cloudflare, you edit them there, and a change made in any other panel never goes live. Keep a complete list of the current records for rollback.
An access note for agencies. Adding and changing domains in Microsoft 365 requires the Domain Name Administrator role. In Google Workspace, activating Gmail for a domain needs the domain settings administrator privilege, and generating the DKIM key needs a super administrator. Rather than sharing the client’s password, give the person doing the work the role they need on a separate account, only for the duration of the job, and keep a written record of who holds the DNS, email and hosting accounts.
2. Take the verification and MX values from the provider
First add the domain to the email provider and verify ownership, then create every mailbox; change the MX only after that. The table below shows only the format; do not copy its values.
| Record type | Microsoft 365 | Google Workspace |
|---|---|---|
| Ownership verification | The TXT record shown in the admin center under Settings → Domains → Add domain. | The google-site-verification=… TXT record shown in the Admin console under Account → Domains → Manage domains. |
| MX | Name @, priority usually 0. The target is specific to your domain; take it from the admin center: it may end in …mail.protection.outlook.com or in …mx.microsoft, the format Microsoft is phasing in for new domains. | Name @ or blank, target smtp.google.com, priority 1. The aspmx values on accounts created before 2023 are still supported. |
| SPF mechanism | include:spf.protection.outlook.com; Microsoft recommends -all. | include:_spf.google.com; Google recommends ~all. |
| DKIM | selector1._domainkey and selector2._domainkey CNAME records; values in the Defender portal. | google._domainkey TXT record; value in the Admin console. |
- A day before the change, lower the TTL of the current MX records (for example to 3,600 seconds); if the old MX is on the hosting server, select Local Mail Exchanger in Email Routing (step 3). Then, at the authoritative DNS, add the new MX record with the provider’s target and priority; the target is a server name, not an IP address. If your panel expects a trailing dot (
smtp.google.com.), follow its format. - Remove the MX records that point to the hosting server or a previous provider; Google asks for every other MX record to be removed.
- In the Microsoft 365 set-up wizard, select Continue after adding the records; in the Google Admin console, complete the Activate Gmail step on the Manage domains page. Google notes that a new MX record can take up to 72 hours to be recognised.
For the screens, follow Microsoft’s DNS records article and Google’s MX article; for MX structure, follow the DNS records guide.
3. Set cPanel’s Email Routing to Remote
If cPanel treats the domain as local, the form messages your website sends to info@ and mail from other accounts on the same server never leave for Microsoft 365 or Google; they are dropped into a local mailbox or bounce as undeliverable. When a domain’s mail host changes, its email routing must change too (cPanel knowledge base).
- If you selected Local, wait until the old MX record’s TTL has expired; then open Email Routing in the Email section of cPanel.
- Choose the domain from the Domain menu.
- Select Remote Mail Exchanger and click Change (cPanel documentation).
Automatically Detect Configuration reads the MX records from the DNS zone stored on this server, not from public DNS (automatic detection rules); if your DNS is hosted elsewhere, the old MX left in the local zone can keep the domain Local. If your email is hosted elsewhere, set Remote explicitly, and repeat this for every domain that uses the same provider.
With Remote selected, the server no longer accepts mail for the domain: mail from senders still using the cached old MX answer bounces, the cPanel mailboxes stop receiving new messages, and forwarders and autoresponders stop working. Recreate the ones you need at the email provider, and use the email migration plan for existing messages, including any that reached the local mailboxes while you waited. Keeping some addresses of the same domain on cPanel and others with an external provider is not supported by the default configuration. If the screen is missing or the setting will not save, the Email Routing feature may be switched off; open a request through the support centre.
4. Clean up the old mail records on the hosting server
If your DNS is managed in cPanel, open Zone Editor in the Domains section and select Manage for the domain. Leave the website’s A, AAAA and www records alone, and check these records.
- autoconfig, autodiscover and
_autodiscover._tcp: cPanel can create email-client records under these names. Once email has left the hosting server, they can send clients to the old server; remove them and check that they have not come back after an account transfer. - Autodiscover on Microsoft 365: Microsoft lists this CNAME record as optional but recommended. First delete the A record, and any AAAA record, named
autodiscover, then add the CNAME record the admin center gives you; a name that holds a CNAME cannot hold any other record (RFC 1034, 3.6.2). - If you cannot see or add the records: in Zone Editor, your account needs the Email Routing feature for MX records, and the Advanced Zone Editor feature for TXT and SRV records and for cPanel-generated records such as autodiscover and autoconfig. Ask for the change in a support request.
5. Merge SPF into one record and turn on DKIM
A domain can have only one SPF record; if two separate v=spf1 records are published, the SPF result is permerror (RFC 7208). If the hosting server (step 6) or other services such as newsletter, CRM or invoicing tools also send on behalf of your domain, add them to the same record. Do not paste the examples below as they stand: 203.0.113.10 is an address reserved for documentation; take the mechanism the hosting server needs from your service instructions or from the SPF record suggested on cPanel’s Email Deliverability screen (cPanel documentation).
Microsoft 365 and the hosting server: v=spf1 ip4:203.0.113.10 include:spf.protection.outlook.com -all Google Workspace and the hosting server: v=spf1 ip4:203.0.113.10 include:_spf.google.com ~all
On shared hosting the server’s IP address is usually shared with other accounts; once it is in your SPF record, those accounts pass SPF for your domain too. Where possible, send the form through the provider’s SMTP; on the hosting route, check in the headers that DMARC passes through DKIM alignment.
End the record with a single -all or ~all. Terms such as include, a and mx need DNS lookups, and if they exceed 10 the result is again permerror; ip4 does not count towards this limit. The SPF record cPanel suggests may account only for the hosting server; before you press Repair or Install the Suggested Record, check that the Microsoft or Google mechanism is kept. If DNS is on cPanel, enter the merged record in Zone Editor as a single v=spf1 TXT record; the Include List field on the Customize screen accepts neither the include: prefix nor _spf.google.com.
DKIM is set up separately for each sender. In Microsoft 365, select the domain on the DKIM tab of the Email authentication settings page in the Defender portal (using Create DKIM keys first if needed), publish the two CNAME records it gives you and turn on Sign messages for this domain with DKIM signatures (Microsoft DKIM article). In Google Workspace, you can get the DKIM key 24–72 hours after Gmail is activated; then generate it under Apps → Google Workspace → Gmail → Authenticate email (2048-bit where supported), add the google._domainkey TXT record and click Start authentication; authentication can take up to 48 hours to start (Google DKIM article). If the hosting server will send form mail, copy the default._domainkey record from Email Deliverability → Manage to the authoritative DNS exactly; if your DNS panel does not split values longer than 255 characters, use the Split view on that screen. cPanel does not sign outgoing mail when the DKIM record at the authoritative DNS does not match the one on the server (cPanel knowledge base).
6. Choose how the contact form sends
DMARC requires the visible From domain to align with a domain authenticated by SPF or DKIM (RFC 9989, which replaced RFC 7489). Do not put the visitor’s address in From; use Reply-To so that replies reach them.
- The provider’s SMTP service: The form authenticates with a separate licensed mailbox to Microsoft 365 (
smtp.office365.com, port 587, STARTTLS) or to Google (smtp.gmail.com, port 465 or 587), and the message leaves through the provider’s SPF and DKIM set-up. On Microsoft 365, use OAuth rather than a password: basic authentication fails in tenants with Security defaults turned on, and Microsoft is switching it off by default for existing tenants from the end of December 2026. In tenants created after January 2020, SMTP AUTH is off by default; turn it on for the sending mailbox. Since 1 May 2025, Google Workspace accounts have not supported less secure apps; you need OAuth, or an app password on an account with 2-Step Verification turned on. The credentials are stored on the website, so do not connect anyone’s personal mailbox, and use this mailbox as theFromaddress too. On servers with SMTP Restrictions enabled, the website cannot connect to remote SMTP servers (cPanel documentation); if your plugin offers one, use its Microsoft Graph or Gmail API option, which works over HTTPS, or open a support request. - The hosting server: The form sends through PHP or the server’s SMTP; add the SPF and DKIM records from step 5 and use an address on your domain for both
Fromand the envelope sender (Return-Path): SPF checks the envelope sender, and PHPmail()sets it only with-f. With Email Routing set to Remote, messages to addresses such asinfo@go to the provider’s MX server. IfRejectDirectSendis on in Microsoft 365 (mandatory in new tenants from November 2026), messages whose envelope sender is on your domain are rejected with550 5.7.68; send the form through the provider’s SMTP. - SMTP relay: Microsoft’s connector-based SMTP relay method cannot be used from third-party hosting services. Google’s SMTP relay service identifies the sender by IP address, by SMTP authentication with a Workspace account, or both; on a shared IP address, do not rely on IP authorisation alone.
Details: Microsoft’s article on sending from applications, the SMTP AUTH timeline, the Direct Send control and Google’s article on sending from apps.
7. Test receiving, sending and the form separately
- Ask your own resolver and the authoritative name server for the MX answer:
nslookup -type=MX example.comandnslookup -type=MX example.com ns1.provider.example. Only the provider’s target should appear; until the old TTL expires, some resolvers may still return the old answer (method in the DNS guide). - Send a message from an outside address to your
info@address and confirm that it arrives in the Microsoft 365 or Gmail mailbox. - Write from the mailbox to an outside address and look for
spf=passanddkim=pass, anddmarc=passif you publish a DMARC record, in the headers of the received message. - Submit a form on the website that contains no personal data. Confirm that the message reaches the inbox and, if you publish a DMARC record, that DMARC passes in the headers; if the form sends from the hosting server, use cPanel’s Track Delivery screen to see that it was delivered to the remote server, not to a local mailbox.
- Check the domain’s status in the Microsoft 365 admin center, or the Gmail activation and DKIM status in the Google Admin console.
If you have no DMARC record, start with a monitoring policy until every sending source is verified; the steps are in the email delivery guide. If a problem remains, prepare your support request with the full error text, the test time and the header results. If you are planning new hosting, explore the business hosting plans.
Host your website on a business hosting plan.
Each plan’s resources and current prices are on the product page; if your email stays on Microsoft 365 or Google Workspace, follow this guide’s order during set-up.