#70 subfolder delivery option


Postfix's 'virtual' delivery process is able to deliver emails to a subfolder of a maildir, if one instructs it to do that. For that purpose 'maildir' has to look like '/var/vmail/domain/user/.subfolder/'. This is usefull for extension based email sorting obviously (letting a mailing list send you emails at user-subfolder@domain). BUT virtual doesn't look for a .forward-... file (which the other delivery process 'local' does). Instead postfix searches for the full email address (avec extension) and in the case it doesn't find it looks for the email address without the extension. So writing a simple line into the mailbox-table that contains the email address user-subfolder@domain and the maildir /domain/user/.subfolder/ would actually do the job.

I think it would be nice to have a feature implemented that enables users (or at least admins) to add extension based subfolder-delivery to their mail delivery.

While we're at it, we could have a general domain-based option that would enable postfix to autocreate subfolders in maildirs. A simple column 'autofolder' could be parsed in the postfix query to determine, if extension-based automatic subfolders would be generated (i admit, this could be a security issue). Here is a postfix query, that i'm using to get the job done at the moment (having added the 'autofolder' manually). First it tries to find the exact email address with the extension. When it doesn't find it, it looks at 'autofolder'. If 'autofolder' is <>'1' then it will not instruct postfix to autodeliver to a subfolder, but rather returns the standard folder for this mailbox (sans extension). If 'autofolder' is '1', then the query would build a folderstructure with the extension(s) as subfolder(s).

Hope you like!

(SELECT maildir from mailbox where
username='%s' and active=1),
(SELECT count(*) from domain where domain = SUBSTRING_INDEX( '%s', '@',-1) and active=1 and autofolder=1)>0,
(SELECT maildir FROM mailbox WHERE username=
CONCAT( SUBSTRING_INDEX( SUBSTRING_INDEX( '%s', '@', 1), '+',1), '@', SUBSTRING_INDEX( '%s', '@',-1))
AND active=1)
(SELECT maildir FROM mailbox WHERE username=
CONCAT( SUBSTRING_INDEX( SUBSTRING_INDEX( '%s', '@', 1), '+',1), '@', SUBSTRING_INDEX( '%s', '@',-1))
AND active=1),
REPLACE(SUBSTRING('%s',LOCATE('+','%s')+1,(SELECT '%s' REGEXP '\\+') * LOCATE('@','%s')-LOCATE('+','%s')-1),'+','/.'),
) as maildir


Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks