rev 1500 - trunk/siesta/lib/Siesta/Plugin

[prev] [thread] [next] [lurker] [Date index for 2004/04/06]

From: richardc
Subject: rev 1500 - trunk/siesta/lib/Siesta/Plugin
Date: 13:01 on 06 Apr 2004
Author: richardc
Date: 2004-04-06 13:01:31 +0100 (Tue, 06 Apr 2004)
New Revision: 1500

Modified:
   trunk/siesta/lib/Siesta/Plugin/Send.pm
Log:
batching of identical message bodies - could be kinder on the MTA


Modified: trunk/siesta/lib/Siesta/Plugin/Send.pm
===================================================================
--- trunk/siesta/lib/Siesta/Plugin/Send.pm	2004-04-06 10:20:47 UTC (rev 1499)
+++ trunk/siesta/lib/Siesta/Plugin/Send.pm	2004-04-06 12:01:31 UTC (rev 1500)
@@ -12,6 +12,7 @@
     my $self = shift;
     my $mail = shift;
 
+    my %messages;
     my $list = $self->list;
   USER: for my $user ($list->members) {
         next if $user->nomail;
@@ -22,10 +23,18 @@
             $plugin->member($user);
             next USER if $plugin->process($message);
         }
-        Siesta->sender->send( $message,
-                              to   => $user->email,
+        my $stringy = $message->as_string;
+        $messages{ $stringy } ||= {
+            message    => $message,
+            to         => [],
+           };
+        push @{ $messages{ $stringy }{to} }, $user->email;
+    };
+    for my $batch (values %messages) {
+        Siesta->sender->send( $batch->{message},
+                              to   => $batch->{to},
                               from => $list->return_path,
-                            );
+                             );
     }
     return;
 }

Generated at 13:57 on 01 Jul 2004 by mariachi 0.52