Dnia 4.05.2021 o godz. 14:55:29 post...@ptld.com pisze: > Using Linux, postfix, dovecot. > > For sorting incoming mail into different maildir folders, i know > general advice is to have postfix deliver to dovecot instead of > maildir, and use dovecot sieve to deliver the mail into a user's > sub-folder. > > Is there anyway within postfix (or policy service) to deliver to a > user's maildir sub-folder (based on from address) without relying on > dovecot?
I once did something similar, but not based on "From:" address, but rather a particular recipient domain. I was using a very simple web form that was sending mail, and I wanted copies of these mails to be stored in my "Sent" folder, as it is with mails sent from regular mail client. I made up a virtual domain copyself.rafa.eu.org (this domain is not even in the DNS, as it has to be recognized only by Postfix on the same server I'm sending mail from). The intent of this domain is that every message sent to r...@copyself.rafa.eu.org (the web form automatically Bcc's messages to this address) is placed in my "Sent" folder. I have added the following to main.cf: virtual_mailbox_domains=copyself.rafa.eu.org virtual_mailbox_base=/home virtual_mailbox_maps=hash:/etc/postfix/copyself In my case the file /etc/postfix/copyself contains only an entry for one user: r...@copyself.rafa.eu.org raj/Maildir/.Sent/ These parameters together cause Postfix to treat the folder /home/raj/Maildir/.Sent as an inbox for user r...@copyself.rafa.eu.org and deliver messages there. Of course in case of multiple users, you can think of some "smart" method of assigning mailboxes to the usernames instead of listing them all in the file like above. There are also two more parameters in main.cf (and two more files), because you have to care for proper permissions when accessing the mailbox: virtual_uid_maps=hash:/etc/postfix/copyself_uids virtual_gid_maps=hash:/etc/postfix/copyself_gids Files /etc/postfix/copyself_uids and /etc/postfix/copyself_gids contain also single line each, specifying the proper UID and GID for accessing the maildir, like: r...@copyself.rafa.eu.org XXXX where XXXX is the proper numeric UID or GID. In case of multiple users, you can also think of some "smart" way to map this. For my purpose (delivering to Sent folder) it works well. You can think of creating something similar if you only want to deliver to a particular folder. For something more general, however, using sieve (or even procmail, as mentioned) would be definitely a better solution. -- Regards, Jaroslaw Rafa r...@rafa.eu.org -- "In a million years, when kids go to school, they're gonna know: once there was a Hushpuppy, and she lived with her daddy in the Bathtub."