Support internal mail ouput redirector
authorJoey Schulze <joey@infodrom.org>
Sat, 7 Jun 2008 14:04:06 +0000 (14:04 +0000)
committerJoey Schulze <joey@infodrom.org>
Sat, 7 Jun 2008 14:04:06 +0000 (14:04 +0000)
src/InfoCon/buch/infocon

index 49cd230..8147a3e 100755 (executable)
@@ -408,6 +408,7 @@ sub usage
     'unpay' => undef,
     'hide' => undef,
     'unhide' => undef,
     'unpay' => undef,
     'hide' => undef,
     'unhide' => undef,
+    'mailto' => undef,
     'buchung-input' => undef,
     'buchung-unpaid' => undef,
     'buchung-hidden' => undef,
     'buchung-input' => undef,
     'buchung-unpaid' => undef,
     'buchung-hidden' => undef,
@@ -421,6 +422,7 @@ my %options = (
     'unhide=s' => \$data{unhide},
     'year=i' => \$opt_year,
     'direction=s' => \$opt_direction,
     'unhide=s' => \$data{unhide},
     'year=i' => \$opt_year,
     'direction=s' => \$opt_direction,
+    'mailto:s' => \$data{mailto},
     'all' => \$opt_all,
     'verbose' => \$opt_verbose,
     'help' => \&usage,
     'all' => \$opt_all,
     'verbose' => \$opt_verbose,
     'help' => \&usage,
@@ -431,6 +433,7 @@ my %options = (
     'list-categories|lc' => \$data{'list-categories'},
     );
 
     'list-categories|lc' => \$data{'list-categories'},
     );
 
+my $cmdln = 'infocon ' . join (' ', @ARGV);
 GetOptions(%options);
 
 if ($opt_year != 0 && $opt_year < 2002) {
 GetOptions(%options);
 
 if ($opt_year != 0 && $opt_year < 2002) {
@@ -441,6 +444,19 @@ if (defined $opt_direction) {
     usage unless $opt_direction =~ /^(in|out)$/i;
 }
 
     usage unless $opt_direction =~ /^(in|out)$/i;
 }
 
+if (defined $data{mailto}) {
+    if (open(STDOUT, "| /usr/sbin/sendmail -t")) {
+       print  "From: Joey Schulze <joey\@infodrom.org>\n";
+       printf "To: %s\n", length($data{mailto})?$data{mailto}:'Joey Schulze <joey@infodrom.org>';
+       printf "Subject: %s\n", $cmdln;
+       print  "MIME-Version: 1.0\n";
+       print  "Content-type: text/plain; charset=iso-8859-1\n";
+       print  "Content-Disposition: inline\n";
+       print  "Content-Transfer-Encoding: 8bit\n";
+       print  "\n";
+    }
+}
+
 if (defined $data{category}) {
     if (length($data{category})) {
        sales_list("category = '".$data{category}."'");
 if (defined $data{category}) {
     if (length($data{category})) {
        sales_list("category = '".$data{category}."'");