summaryrefslogtreecommitdiffstats
path: root/web/attachments/239424-check_email_loop.diff
blob: e06de636fb990367a4efca638c548d0347959f03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
Index: etch/contrib/check_email_loop.pl
===================================================================
--- etch/contrib/check_email_loop.pl    (revision 172)
+++ etch/contrib/check_email_loop.pl    (working copy)
@@ -112,6 +112,7 @@
 # creating new serial id
 my $serial = time();
 $serial = "ID#" . $serial . "#$$";
+push @messageids, $serial;


 # sending new ping email
@@ -136,6 +137,7 @@
 # no the interessting part: let's if they are receiving ;-)

 $pop = Net::POP3->new( $pophost,
+                Debug=>$debug,
                 Timeout=>$poptimeout)
        || nsexit("POP3 connect timeout (>$poptimeout s, host: $pophost)",'CRITICAL');

@@ -154,6 +156,7 @@
   @msglines = @{$pop->top($msgcount,1)};
   for (my $i=0; $i < scalar @messageids; $i++) {
     if (messagematchsid(\@msglines,$messageids[$i])) {
+      warn "Found message $messageids[$i]\n" if $debug;
       $matchcount++;
       # newest received mail than the others, ok remeber id.
       if (!defined $newestid) {
@@ -177,6 +180,7 @@
        chomp @msgsubject;
        # Scan Subject if email is an Email-Ping. In fact we match and delete also successfully retrieved messages here again.
        if (!defined $keeporphaned && $msgsubject[0] =~ /E-Mail Ping \[/) {
+               warn "Deleting orphan: $msgsubject[0]\n";
            $pop->delete($msgcount);  # remove E-Mail from POP3 server
        }

@@ -200,10 +204,7 @@
 }

 # Write list to id-Database
-foreach my $id (@messageids) {
-  print STATF  "$id\n";
-}
-print STATF "$serial\n";     # remember send mail of this session
+print STATF map { "$_\n" } @messageids;
 close STATF;

 # ok - count lost and pending mails;