求助:为基于WHM/cPanel的邮件服务器配置各类DNS记录
Hey there! Let's get your email setup sorted for mysite.com on WHM/cPanel. You’re already off to a good start with planning the A record for mail.mysite.com—here’s the full breakdown of what else you need to do, step by step:
Since your DNS is managed by dnsprovider.com, log into their dashboard and add these critical records alongside your existing mail.mysite.com A record:
- MX Record: Set
mysite.comto point tomail.mysite.comwith a priority of 0 (this is the primary mail exchanger; use the lowest priority number if you add backup MX records later). - SPF TXT Record: For
mysite.com, add a record with the value:
Thev=spf1 +a +mx +ip4:111.222.333.444 +include:cpanel.net ~all~allmeans "soft fail" (it flags unauthenticated mail but still delivers it)—you can switch to-all(strict fail) once you confirm everything works. Adjustinclude:cpanel.netif your WHM/cPanel uses a custom relay, but this is standard for most setups. - DKIM TXT Record: You’ll get this directly from cPanel. Log into your cPanel account, navigate to Email > Authentication, find the DKIM section, and copy the generated record. Add it to your DNS with the name provided (usually something like
default._domainkey.mysite.com) and the corresponding value. - DMARC TXT Record: Add a record for
_dmarc.mysite.comwith:
Start withv=DMARC1; p=none; sp=none; rua=mailto:dmarc@mysite.comp=noneto monitor unauthenticated mail without blocking it. Once you’re confident in your setup, switch top=quarantineorp=rejectto enforce stricter rules.
Now head over to your WHM/cPanel to make sure the server is set up to handle mail correctly:
- Confirm Exim is Running: Log into WHM, go to Service Configuration > Service Manager, and ensure the Exim Mail Server is enabled and active.
- Set Up Email Accounts: In cPanel, go to Email > Email Accounts and create the addresses you need (e.g.,
support@mysite.comoradmin@mysite.com). - Configure Email Routing: In cPanel, navigate to Email > Email Routing. For
mysite.com, select Local Mail Exchanger—this tells the server to process mail locally instead of forwarding it to an external service. - Reverse DNS (PTR) Record: This is critical to avoid your mail being marked as spam. You’ll need to set this up with your server’s hosting provider (not your DNS registrar). The PTR record should map your server IP
111.222.333.444tomail.mysite.com. Most hosts let you set this in their server dashboard or via a support ticket.
Once all records are in place (give DNS up to 24 hours to propagate, though it often happens faster), test your setup:
- Send/Receive Test Emails: Send a message from your new cPanel email to an external account (Gmail, Outlook, etc.) and vice versa to confirm both incoming and outgoing mail works.
- Verify Records via Command Line: Use
digon your server to check if your DNS records are propagating correctly:- Check SPF:
dig TXT mysite.com - Check DKIM:
dig TXT default._domainkey.mysite.com - Check MX:
dig MX mysite.com
- Check SPF:
- Check Exim Logs: If you run into issues, review the Exim logs in WHM at Service Configuration > Mail Server Configuration > View Logs, or via SSH with:
This will show real-time details about incoming/outgoing mail errors.tail -f /var/log/exim_mainlog
One final note: Make sure your server IP isn’t listed on any spam blacklists. If it is, request removal (your hosting provider can help with this, or you can check via command-line tools).
内容的提问来源于stack exchange,提问作者HenryM

