4

I set up a mailing system in my Debian VPS. Everything works smoothly except for I can't send an email to user root.

There is a workaround to specify in /etc/aliases something like

root: <some_other_user>

Then all emails addressed to root@<fqdn> would go into <some_other_user>@<fqdn> mailbox.

From the security perspective it's even better but what I'm wondering about is whether there is a way to send emails to the user root.

So yes, is it possible technically with Postfix? If so, how can I do this?

UPDATE:

Here is postfix.service logs:

Apr 26 22:18:25 <hostname><fqdn> postfix/qmgr[2375]: 3905421760: from=<ddnomad@<fqdn>>, size=631, nrcpt=1 (queue active)
Apr 26 22:18:26 <hostname><fqdn> postfix/local[2429]: 3905421760: to=<mailuser@<fqdn>>, orig_to=<root@<fqdn>>, relay=local, delay=1.3, delays=0.21/0.01/0/1, dsn=2.0.0, status=sent (delivered to command: procmail -a "$EXTENSION")

To my understanding it means that letter was sent successfully. But it never got delivered to root's mailbox.

  • Are you talking about postfix? – Rui F Ribeiro Apr 26 '17 at 20:19
  • Yes, about Postfix. See tags and the last paragraph of my question. – ddnomad Apr 26 '17 at 20:21
  • procmail too? – Rui F Ribeiro Apr 26 '17 at 20:21
  • @RuiFRibeiro in Postfix service logs it says that the email was delivered to a procmail command. I have not tried to send it with procmail only. – ddnomad Apr 26 '17 at 20:23
  • It is a procmail "feature"....root emails go to the nobody user – Rui F Ribeiro Apr 26 '17 at 20:24
6

postfix uses procmail, to deliver email, and as postfix invokes procmail running as nobody for security reasons, emails sent to root will end up being sent to the nobody user.

Debian mailing lists explain it better than me, and suggest a work around:

postfix's own delivery agent can deliver to root's mailbox, but postfix will NEVER fork an external program (e.g. procmail) as root. it either changes UID to the owner of the mail being delivered or if that user is root, then it changes UID to nobody.

so procmail gets run as nobody when delivering root's mail.

i work around this by just symlinking /var/spool/mail/root to /var/spool/mail/nobody - then i can read root's mail as root.
note that this is NOT the recommended way of doing it - most people will recommend that you direct root's mail to another user in /etc/aliases.

Further up in the thread, they also remember the postfix FAQ about root mail:

If you use procmail (or some other command) for local mail delivery, Postfix will not deliver mail as root. Instead, Postfix runs procmail (or whatever) as nobody. Perhaps some day Wietse will trust Postfix enough to run external commands as root. Solution: just like you're not supposed to log in as root (except for unusual conditions), you're not supposed to receive mail as root.

Create a mail alias for root that forwards mail to a real user.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.