[
    {
        "role": "user",
        "content": "It%20seems%20exim%204.9%20is%20delivering%20root%20mail%20to%20user%20mail.%20why%20is%20this%3F"
    },
    {
        "role": "assistant",
        "content": "There are a few reasons why Exim 4.9 (or any version with a similar config) might be delivering mail addressed to `root` into another local user\u2019s mailbox (often \u201cmail\u201d or the first non-root local user). Below are the common causes, how Exim handles `root` deliveries, and what to check to understand *why* it\u2019s happening in your case.\n\n---\n\n## How Exim treats root/local-user delivery\n\n1. **never_users setting**  \n   Exim has a configuration parameter `never_users`, which by default includes `root`. This ensures that Exim never runs a delivery process *as root* for local deliveries (for example, writing to `/var/mail/root`). If a message is addressed to a user in `never_users`, Exim may refuse to run the delivery transport under that user's UID, or treat things specially. ([exim.org](https://www.exim.org/exim-html-current/doc/html/spec_html/ch-main_configuration.html?utm_source=openai))\n\n2. **Alias or forwarding redirect**  \n   Because delivering *as* root is prevented, most systems have an alias in `/etc/aliases` (or equivalent) that redirects root\u2019s email to a non-root user (e.g. `root: admin` or `root: myuser`). That way, mails to root get bounced or redirected to another user before Exim has to try delivering under root UID. ([nsrc.org](https://nsrc.org/wrc/data/2006/1757635379448202b00a1f2/exim_install.html?utm_source=openai))\n\n3. **Qualified domain name / system mail name**  \n   On Debian-derived systems (and configurations using `exim4-config`), there is a \u201cSystem mail name\u201d or \u201cqualify_domain\u201d that tells Exim what hostname/domain names are local. If Exim thinks `root@HOST.DOMAIN` is *not* local (because it doesn\u2019t think the hostname / domain matches local domains), it may rewrite or redirect what \u201croot@something\u201d means (or treat it as remote) and then route differently. ([unix.stackexchange.com](https://unix.stackexchange.com/questions/235112/exim-email-to-root-ignores-etc-aliases-and-root-forward-always-used-qualif?utm_source=openai))\n\n---\n\n## Why you might see root\u2019s mail appearing in another user\u2019s mailbox\n\nGiven the above, here are typical reasons in your situation:\n\n- There is an alias in `/etc/aliases` (or whichever alias file your Exim is configured to use) redirecting `root:` to a user (like `user mail` or simply `user`). So root\u2019s mail gets sent to that user account.  \n- Root's home `.forward` file might redirect to another user, but this may be ineffective if Exim ignores `.forward` for root because of `never_users` or because Exim is built/compiled with certain restrictions. ([exim.org](https://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_default_configuration_file.html?utm_source=openai))  \n- The system\u2019s mail hostname/domain configuration causes Exim to consider `root@hostname` as something to alias to `root@qualified-domain`, and then alias or forward that further. Misconfiguration here can cause weird routing. ([unix.stackexchange.com](https://unix.stackexchange.com/questions/235112/exim-email-to-root-ignores-etc-aliases-and-root-forward-always-used-qualif?utm_source=openai))\n\n---\n\n## What to check in your setup\n\nTo determine *why specifically* Exim 4.9 is doing this on your system, check:\n\n1. **/etc/aliases (or system alias file)**  \n   Look for a line beginning with `root:`. It might redirect root\u2019s mail to another local user. If so, mail is being handled as designed. Check after editing, run `newaliases` (or equivalent) and reload/restart Exim.  \n\n2. **Is there a `.forward` file in `/root/`?**  \n   Sometimes people create `/root/.forward` to forward root\u2019s mail. But this may not work due to `never_users` or ownership / permissions, or because forwarding for root might be disabled.  \n\n3. **Check `never_users` in Exim config**  \n   See whether `root` is in `never_users`, what your `FIXED_NEVER_USERS` setting is, and how the local delivery transport is restricted. If root is in `never_users`, Exim will block local delivery *as root*, so it must go somewhere else. ([exim.org](https://www.exim.org/exim-html-current/doc/html/spec_html/ch-main_configuration.html?utm_source=openai))\n\n4. **Hostname / qualify_domain / local_domains configuration**  \n   Make sure your system\u2019s mail hostname matches the domains that Exim considers local (check `domainlist local_domains`, `qualify_domain` etc.) If root's address is considered to have a domain that is non-local, Exim may try to send it somewhere else (possibly aliasing it).  \n\n5. **Exim logs**  \n   Check the log entries around delivery attempts to `root@`. They may show what alias or rewrite happened (e.g. \u201cR=aliasfile\u201d or \u201cR=localuser\u201d vs \u201cdefer\u201d or \u201cbounce\u201d). That shows which router is catching the `root` address.\n\n---\n\n## Summary\n\n- Exim is unlikely to deliver *to* the `root` user directly under root\u2019s UID, because `root` is in `never_users` by default.  \n- Instead, mails to `root` are typically aliased or forwarded to a non-root user via `/etc/aliases` or `.forward`.  \n- If you see root\u2019s mail arriving in another user\u2019s mailbox, that alias/forward is working.  \n- To change that, edit `/etc/aliases` (or the system\u2019s alias file), create or edit `/root/.forward` (if allowed), adjust `qualify_domain`, and ensure your hostname & local_domains are set properly. Also, modify logs to see which router/transport is being used.\n\nIf you want, I can help you examine your local Exim config (you can paste portions of `exim.conf`) to see *exactly* what\u2019s causing root mail to go to \u201cuser mail\u201d in your case. Would you like to do that?"
    }
]