Configure postfix to deliver mail to particular directory

0

I want to setup postfix so that any outbound mails to admin@mydomain.com are stored locally in to /apps/mails directory and each mail should have file name in YYYY-mm-dd hh.mm.ss.eml Format.

Please suggest me the configuration in postfix to achieve the same.

Best Regards, KJ.

KumarJohn

Posted 2016-11-10T17:00:52.263

Reputation: 223

Answers

0

This is not exactly what you asked for but I was looking for something similar. This may help you out.

Postfix uses mbox by default which stores all emails in one file. You can use the maildir format to get one email per file and a filename that will have a timestamp attached. Maybe the timestamp would be useful for you since you wanted a date in the filename.

Maildir by default delivers to the user's home directory under the Maildir directory. I set "forward_path = /mail/$user/Maildir" in the file /etc/postfix/main.cf. In your case, I believe you just want to set forward_path to "/apps/mails/". If you're dealing with more than one user the $user variable expands to the username which is a nice feature.

Finally, Maildir needs 3 directories - cur, new, and tmp. I added these (e.g. /mail/myuser/Maildir/cur) and changed the owner and group to the user (myuser in this example). I delivered an email and it was delivered properly to the /mail/myuser/Maildir/new directory.

I hope that helps a little!

Chance Chapman

Posted 2016-11-10T17:00:52.263

Reputation: 1