--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/exiacl Tue Aug 02 22:10:18 2005 +0000
@@ -0,0 +1,89 @@
+#! /usr/bin/perl
+# © Heiko Schlittermann
+# $Id$
+# $URL$
+
+use strict;
+use warnings;
+use AppConfig;
+use IPC::Open3;
+use IO::Select;
+use Socket;
+use File::Basename;
+use Sys::Hostname;
+
+
+use constant ME => basename $0;
+use constant CONFIG => (
+ { CASE => 1 },
+ config => { ARGS => "=s", DEFAULT => "exim.conf.t", ALIAS => "C" },
+
+ src => { ARGS => "=s", DEFAULT => "131.107.0.15" },
+ dst => { ARGS => "=s" },
+
+ helo => { ARGS => "=s", DEFAULT => "mail.microsoft.com" },
+
+ From => { ARGS => "=s" },
+ from => { ARGS => "=s", DEFAULT => "hanson\@gmx.net" },
+
+ to => { ARGS => "=s", DEFAULT => "hans\@pobox.com" },
+
+ exim => { ARGS => "=s", DEFAULT => "exim"},
+);
+
+sub exim_option($);
+sub read_exim($);
+
+
+my $Cf;
+$Cf = new AppConfig CONFIG or die;
+ $Cf->dst(inet_ntoa(scalar gethostbyname(exim_option("primary_hostname"))));
+ $Cf->getopt(\@ARGV);
+ $Cf->From($Cf->From || $Cf->from);
+
+my ($w, $r);
+my @cmd = ($Cf->exim, -C => $Cf->config, $Cf->dst ? (-oMi => $Cf->dst) : (), -bhc => $Cf->src);
+
+my $s = new IO::Select;
+
+open3($w, $r, undef, @cmd) or die "Can't run @cmd: $!\n";
+
+read_exim$r;
+print $w "EHLO ".$Cf->helo."\n";
+read_exim($r);
+print $w "MAIL FROM: ".$Cf->From."\n";
+read_exim $r;
+print $w "RCPT TO: ".$Cf->to."\n";
+read_exim $r;
+print $w "DATA\n";
+read_exim $r;
+print $w "From: ".$Cf->from."\n";
+print $w "To: ".$Cf->to."\n";
+print $w "\n.\n";
+read_exim $r;
+print $w "QUIT\n";
+
+
+sub read_exim($) {
+ my $fh = shift;
+ while (<$fh>) {
+ if (/^\d\d\d/) { print; }
+ else { print STDERR; }
+
+ last if /^\d\d\d /;
+ }
+ exit if /^5/;
+}
+
+
+{
+ my %opts;
+sub exim_option($) {
+ my $opt = shift;
+ if (!%opts) {
+ %opts = map { chomp; /^(.*?)\s*=\s*(.*)/ ? ($1, $2) : (/no_(.*)/ ? ($1, 0) : ($_, 1)) } grep !/^\s*$/, `exim -bP`;
+ }
+ $opts{$opt}
+} }
+
+# vim:sts=4 sw=4 aw ai sm: