While working on a project unrelated to Postfix on a CentOS server I noticed an error in the mail logs that indicated an issue with the root users mailbox. I have yet to locate the root cause of the problem however I was able to resolve the problem easily. Below I explain the error in more detail as well as how I was able to resolve the problem with sending email to the root users inbox.

Postfix Error: Unable To Send Mail To root User:

Dec  1 21:43:29 dev-server postfix/qmgr[3273]: BF7B51368032: from=<root@dev-server.somedomain.com>, size=604, nrcpt=1 (queue active)
Dec  1 21:43:29 dev-server postfix/local[16462]: BF7B51368032: to=<root@dev-server.somedomain.com>, relay=local, delay=0.04, delays=0.04/0/0/0, dsn=5.2.0, status=bounced (cannot update mailbox /var/mail/root for user root. cannot create file exclusively: No such file or directory)
Dec  1 21:43:29 dev-server postfix/cleanup[16461]: CA43E1368043: message-id=<20101202024329.CA43E1368043@dev-server.somedomain.com>
Dec  1 21:43:29 dev-server postfix/bounce[16441]: BF7B51368032: sender non-delivery notification: CA43E1368043
Dec  1 21:43:29 dev-server postfix/qmgr[3273]: CA43E1368043: from=<>, size=2701, nrcpt=1 (queue active)
Dec  1 21:43:29 dev-server postfix/smtpd[16459]: disconnect from localhost.localdomain[127.0.0.1]
Dec  1 21:43:29 dev-server postfix/qmgr[3273]: BF7B51368032: removed
Dec  1 21:43:29 dev-server postfix/local[16462]: CA43E1368043: to=<root@dev-server.somedomain.com>, relay=local, delay=0, delays=0/0/0/0, dsn=5.2.0, status=bounced (cannot update mailbox /var/mail/root for user root. cannot create file exclusively: No such file or directory)
Dec  1 21:43:29 dev-server postfix/qmgr[3273]: CA43E1368043: removed

As you can see above there is an issue with the location of root’s mailbox. In fact it appears that roots mailbox no longer exists which is definitely cause for concern. Upon investigating further I noticed that /var/mail is actually a symbolic link to /var/spool/mail as shown in the below output.

Symbolic Link From /var/mail To /var/spool/mail:

[root@dev-server var]# ls -alh | grep mail
lrwxrwxrwx  1 root root   10 Oct 16 12:46 mail -> spool/mail
[root@dev-server var]#

In the above output the symbolic link was flashing indicating that the destination folder or file did not exist. When listing the contents of /var/spool you could see that the mail directory had been renamed to mail.old as shown below.

Contents Of /var/spool On CentOS Linux Server:

[root@dev-server spool]# ls -alh | grep mail
drwxrwxr-x  2 root   mail   4.0K Oct 17 22:50 mail.old
drwx------  2 root   mail   4.0K Mar 31  2010 mqueue
[root@dev-server spool]#

Resolving the problem turned out to be easy by copying the mail.old directory to mail however I am still investigating what caused the issue. Initially I thought it must have been something related to postfix being updated via the yum package manager however the package had not been updated for months. Regardless to resolve the problem use the below syntax from the /var/spool directory.

Copy /var/spool/mail.old To /var/spool/mail On CentOS Linux:

[root@dev-server spool]# cp -pR mail.old/ mail
[root@dev-server spool]#

Now test the solution by attempting to send an email to root from a CentOS Linux shell by using the below syntax. You can replace testmail with any file that has contents while tailing the /var/log/maillog file in another shell window.

Send Email To Root From CentOS Linux CLI:

[root@dev-server ~]# less testmail | mail root
[root@dev-server ~]#

Again the contents of the testmail file was simply some text I had input to test sending mail to the root mail account. The maillog output when sending the email to root is shown in the below example.

The /var/log/maillog Output For The Above Test Email To Root:

Dec  1 21:47:37 dev-server sendmail[16655]: oB22lbcG016655: from=root, size=44, class=0, nrcpts=1, msgid=<201012020247.oB22lbcG016655@dev-server.somedomain.com>, relay=root@localhost
Dec  1 21:47:37 dev-server postfix/smtpd[16459]: connect from localhost.localdomain[127.0.0.1]
Dec  1 21:47:37 dev-server postfix/smtpd[16459]: 3D3CA1368032: client=localhost.localdomain[127.0.0.1]
Dec  1 21:47:37 dev-server postfix/cleanup[16461]: 3D3CA1368032: message-id=<201012020247.oB22lbcG016655@dev-server.somedomain.com>
Dec  1 21:47:37 dev-server sendmail[16655]: oB22lbcG016655: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30044, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 3D3CA1368032)
Dec  1 21:47:37 dev-server postfix/qmgr[3273]: 3D3CA1368032: from=<root@dev-server.somedomain.com>, size=604, nrcpt=1 (queue active)
Dec  1 21:47:37 dev-server postfix/local[16462]: 3D3CA1368032: to=<root@dev-server.somedomain.com>, relay=local, delay=0.06, delays=0.04/0/0/0.02, dsn=2.0.0, status=sent (delivered to mailbox)
Dec  1 21:47:37 dev-server postfix/smtpd[16459]: disconnect from localhost.localdomain[127.0.0.1]
Dec  1 21:47:37 dev-server postfix/qmgr[3273]: 3D3CA1368032: removed

As you can see the test email now sends properly and is delivered to root’s inbox without issue. The root cause should still be investigated which can be completed by trolling through various logs such as /var/log/yum.log, /var/log/messages, lastlog, etc.


List Price: $59.99 USD
New From: $38.78 USD In Stock
Used from: $19.99 USD In Stock

Postfix: The Definitive Guide (Paperback)

By (author): Kyle D. Dent


List Price: $39.99 USD
New From: $22.87 USD In Stock
Used from: $6.38 USD In Stock

DeliciousStumbleUponDiggTwitterFacebookRedditLinkedInEmail
Tags: , , , , , , , , , , , , , ,
Leave a Reply

*Type the letter/number combination in the abvoe field before clicking submit.

*