Centos – What directory permissions does Postfix require to copy mail into a users maildir folder

centosemailpostfixsmtp

I have postfix setup and running. Everything seems good other than the directory permission errors. In the past i accidentally ran chown -R apache / which as you can imagine broke a crazy amount of stuff. Im trying to send an email to a user account called dan. All mail is setup to go to home/user/Maildir

This is the error i get in the log

Jun 10 23:28:51 vps12345 postfix/local[27188]: 4BA06700701:
to=dan@domain.com, relay=local, delay=0.12,
delays=0.09/0.01/0/0.02, dsn=5.2.0, status=bounced (maildir delivery
failed: create maildir file
/home/dan/Maildir/tmp/1433971731.P27188.vps12345.ovh.net: Permission
denied)

I have made sure the directories all exist and i have given them all permission of 777, but no joy. I suspect the ownership might be the issue since root owns everything.

My main issue is i dont know what directories i need to set the permissions correctly for in order to be able to make this work.

In case its needed here is my postfix config

myhostname = mail.domain.com
mydomain = domain.com
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain, mail.$mydomain
mynetworks = 127.0.0.0/8, ipv4, ipv6
relay_domains =
home_mailbox = Maildir/

Im running centos 6.

Best Answer

The MailDir tree should be owned by the user that is getting the message delivered.

You can fix the home directories with this little script.

cd /home
for dir in *; do
    [ -d $dir ] && chown -R $dir $dir
done

This will reset each users home directory tree to be owned by that user. In the rare case that the home directory name does not match the userid this will fail.

Postfix will also need access to its spool directories.

Related Topic