Looks like it might work. Some of the time. It's not 100%, as you might get dups when the hash file rolls over. It's sort of crude, but might meet your objective.

Like Jake said though, I'm not sure this solves the real problem, which lies in how the duplicates come into being in the first place.

Duplicates can also come about due to server performance problems. If you implement this script, it will mask these other duplicates as well, and you might not have any other evidence that a problem exists. This could be dangerous.

Jinu wrote:
Hi

Logically it has to deliver two copies in properly working environment, here I have enclosed the script which referred for the same.

Please check and suggest whether my requirement is possible with below script.

Thanks

Jinu

#! /usr/bin/perl

#----------------------------------------------------------------------

# Copyright 2006 Russell Nelson <[EMAIL PROTECTED]>

# This program is free software; you can redistribute it and/or

# modify it under the same terms as Perl itself.

#----------------------------------------------------------------------

#

#

# Modified for use with vpopmail

# by Chris Hardie <[EMAIL PROTECTED]>

# originally by Russell Nelson, http://www.qmail.org/eliminate-dups

#

#

# Now, if delivery to the mbox is deferred, eliminate-dups will NOT be

# run a second time for the same message.

#

# Set up ~vpopmail/domains/domain.com/.qmail-default as follows:

#

#  | /home/vpopmail/bin/vdelivermail '' [EMAIL PROTECTED]

#

# Then create a ~vpopmail/domains/domain.com/.qmail-delivery file as follows:

#

#  |bin/eliminate-dups domain.com duphash

#  &[EMAIL PROTECTED]

#

# Now, if delivery to the mbox is deferred, eliminate-dups will NOT be

# run a second time for the same message.

my $basedir = "/home/vpopmail/domains";

my $domainname = shift;

my $hname = shift;

my $hashname = "$basedir/$domainname/$hname";

use Digest::MD5;

$md5 = new Digest::MD5;

$loose = 1;                     # loose matching if set.

while(<>) {

   last if /^$/;

   next if $ignore_continue && /^\s/;

   $ignore_continue = 0;

   if (/^received:/i) {

       $ignore_continue = 1;

       next;

   }

   if (!$loose) {

       $headers .= $_;

       next;

   }

   if ($keep_continue && /^\s/) {

       $headers .= $_;

       next;

   }

   $keep_continue = 0;

   if (m/^(from|message-id|date):/i) {

       $headers .= $_;

       $keep_continue = 1;

       next;

   }

   next;

}

$md5->add($headers);

$md5->addfile(STDIN);

$hash = $md5->hexdigest;

print "$headers Our hash:$hash\n";

if (open(HASH, "<$hashname.newer")) {

   flock(HASH, 2);

   while(<HASH>) { chomp; exit 99 if $_ eq $hash; }

}

open(HASH, "<$hashname.older") || die "$0: Cannot open $hashname.older";

while(<HASH>) { chomp; exit 99 if $_ eq $hash; }

# roll the files once a week.

if (-M "$hashname.older" > 7) {

rename("$hashname.newer", "$hashname.older") || die "$0: Unable to move newer to older";

}

# add the hash to the "received messages" list.

open(HASH, ">>$hashname.newer") || die "$0: Cannot append to $hashname.newer";

print HASH "$hash\n";

close(HASH);

print "Original message";

exit 0;

*From:* Jake Vickers [mailto:j...@qmailtoaster.com]
*Sent:* Tuesday, August 18, 2009 4:49 PM
*To:* qmailtoaster-list@qmailtoaster.com
*Subject:* Re: [qmailtoaster] duplicate mail

Jinu wrote:

Hi

I using mail server prepared through qmail toaster. Here I’m facing problem with duplicate mails. If I send mail to multiple alias where same ID included in both alias, two mails will be delivered to user. I just come across the script called eliminate dups. Please help me to implement the same or suggest some solution as I’m new to qmail.

Thanks

Jinu

Doesn't this seem like logical behavior? If you send two copies of the same message to the same use, shouldn't they then get 2 copies? I'd suggest instead of adding a script (I've never heard of your script before) that you rethink the logic of your mail delivery and adjust to not create the problem in the first place, instead of creating the problem and then adding other modifications to then fix the problem you created.
Just my opinion.



--
-Eric 'shubes'


---------------------------------------------------------------------------------
Qmailtoaster is sponsored by Vickers Consulting Group 
(www.vickersconsulting.com)
   Vickers Consulting Group offers Qmailtoaster support and installations.
     If you need professional help with your setup, contact them today!
---------------------------------------------------------------------------------
    Please visit qmailtoaster.com for the latest news, updates, and packages.
To unsubscribe, e-mail: qmailtoaster-list-unsubscr...@qmailtoaster.com
    For additional commands, e-mail: qmailtoaster-list-h...@qmailtoaster.com


Reply via email to