1

I am using postfix, the LDA is dovecot and i found the useful parameter recipient_delimiter in the man page of postfix.

I would like to use mail addresses like user+folder@domain.com and the mail server should automatically move the mail into the appropriate folder. If the folder does not exist, it should get created.

Dovecot can create automatically directories over the configuration files. I have found the following options for it: Mailbox Settings and Autocreate Plugin

So i could write a little bash scripts which reads the mail server logs, greps the mail addresses and either create the maildirectory via mkdir or via the dovecot configuration. But i do not believe that this is the correct solution for it, because:

  1. The first mail would not get catched because the mail folder does not exist at this time. But that is not the main problem, the mail could get moved via the script too.
  2. There must be a better solution for that.

I searched already on the web, but i could not find informations about that. Probably (for sure) i am using the false searching terms.

  • I use the same setting to allow my mail client to do the filtering into subfolders. I also use a hyphen ( - ) instead of a plus since a lot of forum registrations (and my bank) think the plus ( + ) isn't a valid character in an email address. – ivanivan Apr 20 '17 at 20:40
1

Doevecot supports Sieve filters to handle incoming mail. By combining the fileinto module, the :create option of the mailbox module and finally the subaddress extension you will be able to sort mails by their extension into different folders.

This will move all mails to <user>+<tag>@example.org to $tag subdirectories in the tag folder of the inbox.

require ["fileinto", "mailbox", "subaddress", "envelope", "variables"];
if envelope :matches :detail "to" "*" {
  fileinto :create "inbox.tags.${1}";
}
  • Note: I have not verified this very snippet, but constructed it from some other parts of my own Sieve script. If there are any issues, please post the error message. – Jens Erat Apr 20 '17 at 19:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.