In this tutorial, we’ll explain the simplified way how to set up proper DMARC records in cPanel. This allows you to specify how mail servers should handle messages from your domain that do not have valid SPF and DKIM records setup. DMARC is the standard used by most email providers (ie. Gmail, Yahoo, AOL, Outlook). DMARC can help increase your chances of emails being delivered successfully to your recipients’ inbox.
Setting up DMARC Records
- Log into your domain’s cPanel
- Click the Zone Editor button in the Domains section.
- Choose your domain from the drop down box.
- Click the blue +Add Record button and “Add DMARC Record” on the drop down as shown below.

- Choose your options and click “Add Record” once done.
- That’s it!
You can also watch a cPanel video explaining this:
If you are running Dovecot on your cPanel servers, you’ll have noticed that mail trash isn’t auto-deleted which is bloody annoying for you and for your customers.
I’ve found this script on the cPanel forum that will delete email trash that is over 30 days old.
#!/bin/bash
MAILDIRS=$(find /home/*/mail/*/* -maxdepth 0 -type d)
INBOXFOLDERS=(.Trash .Junk .Spam .Low\ Priority .cPanel\ Reports)
for basedir in $MAILDIRS; do
for ((i = 0; i < ${#INBOXFOLDERS[*]}; i++)); do
for dir in cur new; do
[ -e "$basedir/${INBOXFOLDERS[$i]}/$dir" ] && (
echo "Processing $basedir/${INBOXFOLDERS[$i]}/$dir..."
find "$basedir/${INBOXFOLDERS[$i]}/$dir/" -type f -mtime +30 -delete
)
done
done
done
/scripts/generate_maildirsize --verbose --allaccounts --force
To run, SSH into your server and create a file such as delete_email_trash.sh and make sure you give it executable permissions (chmod +x) and then run ./delete_email_trash.sh
I’d add it to a daily cron.
I’ve also put the script online site so you can use wget on the server to save you doing anything, I’ve put it in the /root folder
cd /root
wget http://tomyates.co.uk/auto_delete_spam.sh
chmod +x auto_delete_spam.sh
#add to crontab
(crontab -l; echo "30 1 * * * /root/auto_delete_spam.sh > /dev/null 2>&1") | crontab
#run for first time
/root/auto_delete_spam.sh
source: http://tomyates.co.uk/2012/08/01/auto-delete-trash-folders-on-cpanel-servers-using-dovecot/