HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   General (http://www.howtoforge.com/forums/forumdisplay.php?f=25)
-   -   Email copy and forward problem (http://www.howtoforge.com/forums/showthread.php?t=55650)

ethraza 5th January 2012 21:05

Email copy and forward problem
 
Hi. I'm using ISPConfig 3.0.4.1 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:
a@dom.com <Send copy to> b@dom.com

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:
a@dom.com <Send copy to> cc.a@dom.com (Email forward one)
cc.a@dom.com <Forward a copy to> b@dom.com, c@dom.com, d@dom.com
b@dom.com <Send copy to> x@dom.com
c@dom.com <Send copy to> x@dom.com
d@dom.com <Send copy to> x@dom.com

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:
a@dom.com usrA, usrB, usrC
b@dom.com usrB, usrX
c@dom.com usrC, usrX
...

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


Thanks for any help.

dar_ek 22nd May 2012 23:03

Quote:

Originally Posted by ethraza (Post 270909)
First case:
a@dom.com <Send copy to> b@dom.com

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?

One of solve is to remember what mail we send to CC.
To do this we must generate to ".mailfilter" not only this line:
Code:

cc "!user@domain.com"
(that actually ISPconfig do)
but eg. this code:

Code:

USER=tolower("$3")
HOST=tolower("$4")
`reformail -D 8000 /var/vmail/mailfilters/$HOST/$USER/.duplicate.cache`
if ( $RETURNCODE != 0 )
        cc "!user@domain.com"

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/maildrop_plugin.inc.php file:

Change line:
Code:

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

Code:

                    $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?

regards.

ethraza 29th May 2012 22:34

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.

Thanks

dar_ek 30th May 2012 13:07

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:

Quote:

cc "!FORWARDTO@DOMAIN.COM"
I modify this to that code:

Quote:

#------ get a mailto parts USER@HOST from maildrop enviroment ($3 and $4)
USER=tolower("$3")
HOST=tolower("$4")
#------ I need this to have separate .duplicate.cache file for every users
#------ reformail save ID from mail and return 0 if that mail was in this file already
`reformail -D 8000 /var/vmail/mailfilters/$HOST/$USER/.duplicate.cache`
#------ in other case (file wasn't in .dupicate.cache)
if ( $RETURNCODE != 0 )
cc "!FORWARDTO@DOMAIN.COM"
#------ do a "Send copy to"
#IN OTHER CASE DO NOT CC but only try to put mail to original mailbox (without cc)
of course you must modify "cc "!FORWARDTO@DOMAIN.COM"" 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/maildrop_plugin.inc.php" 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).


All times are GMT +2. The time now is 15:56.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.