Email copy and forward problem

Discussion in 'General' started by ethraza, Jan 5, 2012.

  1. ethraza

    ethraza New Member

    Hi. I'm using ISPConfig with postfix and maildrop on a Ubuntu LTS Server production environment and I'm facing a LOT of problens concerning the email copy feature.

    Don't matter if I use "Send copy to" direct to the Destionation Email or if I "Send copy to" a Email Forward email, in both cases the same problens happens.

    First case:
    [email protected] <Send copy to> [email protected]

    What happens:
    1- a@ reach it's quota limit
    2- Everytime postfix try to delivery a email to a@, in the mail.log we will see "Permission denied maildrop: maildir over quota."
    3- A copy of this email is sent over to b@
    4- Now b@ have a bunch of duplicated emails and they will keep coming till someone clean a@ inbox.

    There is a way to "fix" that?
    I mean, b@ should receive only a copy of the first attenpt or at least a copy of the delivered email, not the denied ones.

    Second case:
    [email protected] <Send copy to> [email protected] (Email forward one)
    [email protected] <Forward a copy to> [email protected], [email protected], [email protected]
    [email protected] <Send copy to> [email protected]
    [email protected] <Send copy to> [email protected]
    [email protected] <Send copy to> [email protected]

    What happens:
    1- a@ got a new mail
    2- A copy goes to cc.a@
    3- cc.a@ forwards a copy to b@, c@ and d@
    4- b@ send a copy to x@
    5- c@ send a copy to x@
    6- d@ send a copy to x@
    7- x@ got 3 new duplicated emails

    I believe that a copied email must stop in his first destination and not spread to the entire chain. The way postfix do when we add more destinations to the virtual file, like in:
    [email protected] usrA, usrB, usrC
    [email protected] usrB, usrX
    [email protected] usrC, usrX

    There is a way to "fix" that spread behavior of ispconfig?

    Thanks for any help.
  2. dar_ek

    dar_ek New Member

    One of solve is to remember what mail we send to CC.
    To do this we must generate to ".mailfilter" not only this line:
    cc "![email protected]"
    (that actually ISPconfig do)
    but eg. this code:

    `reformail -D 8000 /var/vmail/mailfilters/$HOST/$USER/.duplicate.cache`
    if ( $RETURNCODE != 0 )
            cc "![email protected]"
    reformail is a part of courier-maildrop package. -D option do a "Detecting duplicate messages". Thats means that ID's of messages thats already was send (and notified in our .duplicate.cache file are detected and does not resend (cc) on re-queue.

    Patch ISPconfig /usr/local/ispconfig/server/plugins-available/ file:

    Change line:
    $mailfilter_content .= "cc \"!".$data["new"]["cc"]."\"\n";
    To this part:

                         $mailfilter_content .= "USER=tolower(\"\$3\")\n";
                         $mailfilter_content .= "HOST=tolower(\"\$4\")\n";
                         $mailfilter_content .= "`reformail -D 8000 /var/vmail/mailfilters/\$HOST/\$USER/.duplicate.cache`\n";
                         $mailfilter_content .= "if ( \$RETURNCODE != 0 )\n";
                         $mailfilter_content .= "\tcc \"!".$data["new"]["cc"]."\"\n";
    (and recreate CC file if already exists)
    Maybe Till do this in distro?

    Last edited: May 22, 2012
  3. ethraza

    ethraza New Member

    Hi dar_ek.

    Thank you so much for your reply.
    Today I tested you implementation but it didn't work. I tested booth, 1st and 2nd cases and the duplicated emails just keep coming.

    I edited the .mailfilter of my test accounts and added you modifications to the cc line. Maybe I missunderstand something, but just that didn't made any difference other than a message Id been added to the .duplicate.cache for each incoming email.

    If you have any other ideas I can gladly try.

  4. dar_ek

    dar_ek New Member

    hmmm It worked for me :)

    Ok, lets do a step by step once again.

    If we fill "Send copy to" field in ISPCOnfig panel, when ISPC generate file: /var/vmail/mailfilters/DOMAIN/USER/.mailfilter with line:

    I modify this to that code:

    of course you must modify "cc "![email protected]"" to your case.

    If you have generated ".duplicate.cache" file you have reformail command, and it works.

    Maybe we misunderstand.
    I do that a protects from sending CC for every TRY to put SAME mail in mailbox that is overquota.
    But FIRST try of try will DO a CC. And for every (different) new mail that will (try) arrive to mailbox will be a CC too.
    Only RESEND SAME mail from postfix queue to original (overquota) mailbox will not generate NEW CC to "Send copy to" user.

    ps. if it will works however for you too, you need patch ISPC "plugins-available/" file, in order to ISPC generate improvement ".mailfilter" each time user fill "Send copy to" in panel (how do this, I wrote in first reply).

Share This Page