- multiple recipients are allowed
authorheiko
Tue, 03 Jul 2007 15:27:21 +0000
changeset 24 a7a73cba1342
parent 23 f4c012bc97c0
child 25 3f3ae057210b
- multiple recipients are allowed
exiacl.pl
--- a/exiacl.pl	Wed Nov 29 05:55:42 2006 +0000
+++ b/exiacl.pl	Tue Jul 03 15:27:21 2007 +0000
@@ -29,7 +29,7 @@
     Environment used: $EXIM		[!$ENV{EXIM}!]
                       $EXIM_CONF	[!$ENV{EXIM_CONF}!]
 
-    Data is read from STDIN unless it's connected to terminal.
+    mail data is read from STDIN unless it's connected to terminal.
 
     $Id$
     $URL$
@@ -47,7 +47,7 @@
 our $VERSION = "0.8";
 
 sub exim_option($);
-sub read_exim($);
+sub read_exim($;$);
 sub write_exim($@);
 sub addr(@);
 sub hostname() { chomp (my $h = `hostname -f`); return $h;  }
@@ -133,13 +133,17 @@
     $SIG{PIPE} = sub { exit };
     my $pid = open3($w, $r, undef, @cmd) or die "Can't run @cmd: $!\n";
 
+
      read_exim $r;
     write_exim $w, "EHLO ".$Cf->Helo."\n";
      read_exim $r;
     write_exim $w, "MAIL FROM: ".$Cf->From."\n";
      read_exim $r;
-    write_exim $w, "RCPT TO: ".$Cf->to."\n";
-     read_exim $r;
+
+    foreach my $rcpt (split /\s*,\s*/, $Cf->to) {
+	write_exim $w, "RCPT TO: $rcpt\n";
+	 read_exim $r, "5";
+    }
     write_exim $w, "DATA\n";
      read_exim $r;
     write_exim $w, "From: ".$Cf->from."\n";
@@ -160,8 +164,9 @@
 
 }
 
-sub read_exim($) {
+sub read_exim($;$) {
     my $fh = shift;
+    my $oh_my_dear = shift || "54";
     while (<$fh>) {
 	/^\d\d\d/ and print("< $_") and next;
 	/^LOG/ and print and next if $Cf->log;
@@ -169,7 +174,7 @@
     } continue {
 	last if /^\d\d\d\s/;
     }
-    exit if defined and /^[54]/;
+    exit if defined and /^[$oh_my_dear]/;
 }
 
 sub write_exim($@) {