Filter mails by :detail?

Discussion in 'General' started by Qroac, Dec 25, 2017.

  1. Qroac

    Qroac New Member

    Hey there,
    finally I started experiments with + separated detail strings in my mail address on a dovecot-perfect-server setup (debian).
    Goal is to pick up the detail part in custom filters to perform actions with matching emails. But it seems not to work ...
    I added the custom filters as listed below and sent test mails to the mail address. I expected to find mails with +news in the newsletter-folder and those with +social in the social-folder (both created before). But the mails always get stored in the main mailbox.

    require ["fileinto", "envelope", "subaddress"];
    if envelope :detail "to" "news"{
      fileinto "Newsletter";
    if envelope :detail "to" "social"{
      fileinto "Social";
  2. Jesse Norell

    Jesse Norell Well-Known Member

    I'm not familiar with :detail specifically, but I'm guessing you may just need a 'stop; ' in your if blocks to stop further processing.
  3. Qroac

    Qroac New Member

    I added a stop after fileinto, but it still doesn't work.
    :detail comes with pidgeonhole
    The documentation I found tells, that it must be enabled either for dovecot LDA or LMTP.
    What is the difference and which one should I choose in a typical howtoforge debian perfect server setup?
    Furthermore, I am not really familliar with dovecot and sieve configurations, so also this page on dovecot/sieve configuration for pidgeonhole didn't really help me:
    (sorry for links in code block, but I wasn't allowed to post direct links in my second forum post ;) )
  4. Qroac

    Qroac New Member

    Ok, I figured it out.
    1. I wrote a require statement in my custom filter. This way it was placed in the middle of the .sieve file, below the autogenerated junk rule
      Sieve doesn't like requires in the middle of the file.
    2. I copied the sieve config templates to conf-custom and added "envelope", "subaddress" to the require statement
    3. Now I can run custom filters on the detail part of the mail address: mailboxname[+detail] as listed in the first post
    Suggestion to Till, shouldn't be a big change:
    What about adding these imports to the official config script and add a filter selection "If Detail part of Mail Address is/begins/..."
  5. Qroac

    Qroac New Member

    Aw, I also had to tell postfix to pass the origiginal recipient down to dovecot.
    adding -a ${original_recipient} to dovecots pipe in postfix worked it out.
    My success in the previous post came from a regular mailfilter I added via ispconfig ...
    To enable my users to manage :detail filters by themselfes, I also made modifications to ISPConfig which are part of my recent pull request:

Share This Page