131 print "**> @cmd\n"; |
131 print "**> @cmd\n"; |
132 |
132 |
133 $SIG{PIPE} = sub { exit }; |
133 $SIG{PIPE} = sub { exit }; |
134 my $pid = open3($w, $r, undef, @cmd) or die "Can't run @cmd: $!\n"; |
134 my $pid = open3($w, $r, undef, @cmd) or die "Can't run @cmd: $!\n"; |
135 |
135 |
|
136 |
136 read_exim $r; |
137 read_exim $r; |
137 write_exim $w, "EHLO ".$Cf->Helo."\n"; |
138 write_exim $w, "EHLO ".$Cf->Helo."\n"; |
138 read_exim $r; |
139 read_exim $r; |
139 write_exim $w, "MAIL FROM: ".$Cf->From."\n"; |
140 write_exim $w, "MAIL FROM: ".$Cf->From."\n"; |
140 read_exim $r; |
141 read_exim $r; |
141 write_exim $w, "RCPT TO: ".$Cf->to."\n"; |
142 |
142 read_exim $r; |
143 foreach my $rcpt (split /\s*,\s*/, $Cf->to) { |
|
144 write_exim $w, "RCPT TO: $rcpt\n"; |
|
145 read_exim $r, "5"; |
|
146 } |
143 write_exim $w, "DATA\n"; |
147 write_exim $w, "DATA\n"; |
144 read_exim $r; |
148 read_exim $r; |
145 write_exim $w, "From: ".$Cf->from."\n"; |
149 write_exim $w, "From: ".$Cf->from."\n"; |
146 write_exim $w, "To: ".$Cf->to."\n"; |
150 write_exim $w, "To: ".$Cf->to."\n"; |
147 write_exim $w, "Subject: Test\n"; |
151 write_exim $w, "Subject: Test\n"; |
158 write_exim $w, "QUIT\n"; |
162 write_exim $w, "QUIT\n"; |
159 |
163 |
160 |
164 |
161 } |
165 } |
162 |
166 |
163 sub read_exim($) { |
167 sub read_exim($;$) { |
164 my $fh = shift; |
168 my $fh = shift; |
|
169 my $oh_my_dear = shift || "54"; |
165 while (<$fh>) { |
170 while (<$fh>) { |
166 /^\d\d\d/ and print("< $_") and next; |
171 /^\d\d\d/ and print("< $_") and next; |
167 /^LOG/ and print and next if $Cf->log; |
172 /^LOG/ and print and next if $Cf->log; |
168 print and next if $Cf->debug; |
173 print and next if $Cf->debug; |
169 } continue { |
174 } continue { |
170 last if /^\d\d\d\s/; |
175 last if /^\d\d\d\s/; |
171 } |
176 } |
172 exit if defined and /^[54]/; |
177 exit if defined and /^[$oh_my_dear]/; |
173 } |
178 } |
174 |
179 |
175 sub write_exim($@) { |
180 sub write_exim($@) { |
176 my $fh = shift; |
181 my $fh = shift; |
177 print "> ", @_; |
182 print "> ", @_; |