Send patch for discussion

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

From: Richard Clamp
Subject: Send patch for discussion
Date: 18:09 on 05 Apr 2004
The following is a patch for discussion.  It tries to play back into
sendmails hands by trying to send it batches of the same email to
multiple users, as it used to before all this per-user fun.

Index: Send.pm
===================================================================
--- Send.pm	(revision 1486)
+++ Send.pm	(working copy)
@@ -3,6 +3,7 @@
 use strict;
 use Siesta::Plugin;
 use base 'Siesta::Plugin';
+use Digest::MD5 qw( md5_hex );
 
 sub description {
     "dispatch mail to list members";
@@ -12,6 +13,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 +24,18 @@
             $plugin->member($user);
             next USER if $plugin->process($message);
         }
-        Siesta->sender->send( $message,
-                              to   => $user->email,
+        my $md5 = md5_hex( $message->as_string );
+        $messages{ $md5 } ||= {
+            message    => $message,
+            to         => [],
+           };
+        push @{ $messages{ $md5 }{to} }, $user->email;
+    };
+    for my $batch (values %messages) {
+        Siesta->sender->send( $batch->{message},
+                              to   => $batch->{to},
                               from => $list->return_path,
-                            );
+                             );
     }
     return;
 }


Now I've got two concerns.

1) Should this be pushed downward into the Siesta::Send::* classes?
This probably involves adding a ->flush method to them as a
hint/indication that there's nothing more coming up.

2) There's a potential to ballon up and eat all the RAM, if enough
users have customised their mail just for them.  This is a bad thing,
right?


Any comments on that, or anything else?


-- 
Richard Clamp <richardc@xxxxxxxxx.xxx>

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