Era Host hosting
EraHost – Free Domain, Cheap Hosting!
Client Area
Support 24/7
Menu

enforce_mail_permissions in cPanel/Exim

5 min read
03.07.2025

The enforce_mail_permissions setting in Exim — the mail server used by cPanel-based hosting — is a security feature that makes Exim refuse to deliver mail into directories whose ownership or permissions don't match the expected user. It prevents a malicious or misconfigured local account from writing into someone else's mailbox and stops a number of mail-spoofing scenarios on shared servers.

Below is a short reference for system administrators: how to check the current state of the option, how to turn it on or off via WHM or SSH, and how to handle the two error patterns you'll most often see right after enabling it.

This guide assumes root access to a cPanel/WHM server. On managed plans where you don't have WHM root, ask your provider's technical support to flip the option instead of editing /etc/exim.conf by hand.

enforce_mail_permissions in cPanel/Exim
Where enforce_mail_permissions lives in the Exim configuration on a cPanel server.

What enforce_mail_permissions does

  • Ensures every mail file is owned by the expected mailbox user.
  • Blocks mail delivery if the target directory has overly permissive bits.
  • Prevents a number of mail-spoofing patterns on shared hosts where one cPanel account could otherwise touch another account's mail tree.
  • Surfaces broken permissions early instead of letting Exim silently deliver into a directory that other users can read.

Checking the current setting

Print the effective value Exim is running with:

exim -bP | grep enforce_mail_permissions

Expected output on a hardened cPanel box:

enforce_mail_permissions = true

If you see false, the protection is currently off — usually because someone disabled it during troubleshooting and never turned it back on.

Enabling enforce_mail_permissions

Via WHM (Exim Configuration Manager)

  • Log in to WHM as root.
  • Open Service Configuration → Exim Configuration Manager → Advanced Editor.
  • Find the enforce_mail_permissions directive and set it to true.
  • Click Save. WHM will restart Exim automatically.

Via SSH

  • Open the Exim config:
    nano /etc/exim.conf
  • Add or change the line:
    enforce_mail_permissions = true
  • Save the file (Ctrl + X, then Y).
  • Restart Exim:
    systemctl restart exim
  • Verify the new value:
    exim -bP | grep enforce_mail_permissions
Tip Editing /etc/exim.conf directly is supported on cPanel servers, but WHM may overwrite parts of the file during certain upgrades. If you want the change to survive, prefer the Advanced Editor route described above.

Disabling enforce_mail_permissions

Not recommended Turn the setting off only for short-term debugging and remember to switch it back on. Leaving enforce_mail_permissions = false on a shared server makes a whole class of cross-account mail attacks easier to execute.
  • Edit Exim's config:
    nano /etc/exim.conf
  • Change the value:
    enforce_mail_permissions = false
  • Restart Exim and reproduce the issue you're debugging:
    systemctl restart exim
  • Once the diagnosis is done, set the value back to true and restart Exim again.

Troubleshooting common issues

Mail delivery fails after enabling the setting

A user reports bounces with the following SMTP response:

550-5.7.1 Your mail directory has incorrect ownership or permissions

This means Exim refused to write into the user's mail tree because something in /home/<user>/mail is not owned by the mailbox user or has wider permissions than expected. Fix the ownership and the mode:

chown -R user:mail /home/user/mail
chmod -R 700 /home/user/mail

Replace user with the actual cPanel account name. After that, mail delivery should resume on the next retry. Symptoms similar to "Rejected Relay Attempt" in cPanel can sometimes be caused by the same root issue, so it's worth checking both directions.

Mail stuck in the queue

If Exim accepted the message but never delivered it locally, force the queue to run:

exim -qff

Then watch /var/log/exim_mainlog for the actual delivery error. If you see permission-denied entries, you'll need to fix ownership as shown above before the queue can drain.

If the failure is not at the Exim layer at all but inside PHP — for example, a script can't send mail through mail() — the cause is usually unrelated to enforce_mail_permissions. See Fix: mail() Has Been Disabled for Security Reasons in PHP for the disabled-functions angle.

cPanel Hosting
Full control over your website
  • Convenient
  • Simple
  • Fast
  • Free 7-day trial
cPanel Hosting

When to keep it enabled

  • Shared hosting: keep it on. The risks it mitigates are exactly the ones shared hosts care about.
  • Compliance: if you're audited for tenant isolation, this is one of the boxes auditors look for.
  • Single-tenant servers: still leave it on. The performance cost is negligible and it surfaces permission drift you'd otherwise miss.
  • Turning it off: reserve for short troubleshooting windows, never as a permanent fix.

For broader cPanel administration tasks unrelated to Exim, our cPanel hosting login and website setup guide walks through the typical day-one tasks on a new cPanel account.

Quick reference
  • Status: exim -bP | grep enforce_mail_permissions
  • Enable (recommended): set enforce_mail_permissions = true in /etc/exim.conf and restart Exim.
  • Fix bounces after enable: chown -R user:mail /home/user/mail & chmod -R 700 /home/user/mail.
  • Restart Exim: systemctl restart exim.
Frequently asked questions
It blocks a class of cross-account mail attacks on shared hosting. With the option on, Exim refuses to deliver into a mail directory whose ownership or permissions don't match the expected mailbox user, so a malicious or misconfigured account can't end up writing into someone else's mailbox.
Run exim -bP | grep enforce_mail_permissions in SSH. The output will be either enforce_mail_permissions = true (enabled) or false (disabled). The same value is shown in WHM under Service Configuration → Exim Configuration Manager → Advanced Editor.
For a short debugging window, yes — long-running operators do it routinely. The rule is to turn it back on as soon as the diagnosis is finished. Leaving it off permanently on a shared server defeats the purpose of having it at all.
Exim is refusing to write into a mailbox whose tree is owned by the wrong user or has wider permissions than 0700. Fix it with chown -R user:mail /home/user/mail and chmod -R 700 /home/user/mail (substitute the real cPanel account name for user). After Exim retries, the bounces stop.
On a cPanel server, the canonical place is /etc/exim.conf. You can edit it directly, but WHM's Advanced Editor is the supported path because some cPanel upgrades may rewrite parts of the file.
Related articles
Error: "Domain has exceeded the max defers and failures per hour (5/5 (100%)) allowed. Message discarded."
Check MySQL Event Scheduler Status & Enable It Temporarily
Fix: proc_open() Has Been Disabled for Security Reasons