X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-receivables-report;h=f3ad2a1a61160e40bf499a832a1a8168f3b9cb7d;hb=91292eadb6254740a9b72e5dc95f575593f6a35d;hp=c4d188c4e82d480a42bad983804053cba59257ed;hpb=f9734784e69f0a24e25fdeb6554d6563577e9296;p=freeside.git diff --git a/FS/bin/freeside-receivables-report b/FS/bin/freeside-receivables-report index c4d188c4e..f3ad2a1a6 100755 --- a/FS/bin/freeside-receivables-report +++ b/FS/bin/freeside-receivables-report @@ -5,16 +5,17 @@ use Date::Parse; use Time::Local; use Getopt::Std; use Text::Template; +use Net::SMTP; +use Mail::Header; +use Mail::Internet; use FS::Conf; use FS::UID qw(adminsuidsetup); use FS::Record qw(qsearch); use FS::cust_main; -# Set the mail program -my $mail_program = "/usr/sbin/sendmail -t -n"; &untaint_argv; #what it sounds like (eww) -use vars qw($opt_v $opt_p $opt_m $opt_e $opt_t $report_lines $report_template @buf); +use vars qw($opt_v $opt_p $opt_m $opt_e $opt_t $report_lines $report_template @buf $header); getopts("vpmet:"); #switches #we're at now now (and later). @@ -34,6 +35,9 @@ adminsuidsetup $user; my $conf = new FS::Conf; my $lpr = $conf->config('lpr'); my $email = $conf->config('email'); +my $smtpmachine = $conf->config('smtpmachine'); +my $mail_sender = $conf->exists('invoice_from') ? $conf->config('invoice_from') : + 'postmaster'; my @report_template = $conf->config('report_template') or die "cannot load config file report_template"; $report_lines = 0; @@ -65,14 +69,14 @@ if ($lpr && $opt_p) if ($email && $opt_m) { - open (MAIL, "|$mail_program"); - print MAIL < $header, + 'Body' => [ (@report) ], + ); + $!=0; + $message->smtpsend( Host => "$smtpmachine" ) + or die "can't send report to $email via $smtpmachine: $!"; } @@ -148,7 +157,7 @@ if($email && $opt_m) sub untaint_argv { foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV - $ARGV[$_] =~ /^([\w\-\/ ]*)$/ || die "Illegal argument \"$ARGV[$_]\""; + $ARGV[$_] =~ /^([\w\-\/ \.]*)$/ || die "Illegal argument \"$ARGV[$_]\""; $ARGV[$_]=$1; } } @@ -169,21 +178,21 @@ freeside-receivables-report - Prints or emails outstanding receivables. Prints or emails outstanding receivables --v: Verbose - Prints records to STDOUT. +B<-v>: Verbose - Prints records to STDOUT. --p: Print to printer lpr as found in the conf directory. +B<-p>: Print to printer lpr as found in the conf directory. --m: Mail output to user found in the Conf email file. +B<-m>: Mail output to user found in the Conf email file. --e: Print a final form feed to the printer. +B<-e>: Print a final form feed to the printer. --t: supply a title for the top of each page. +B<-t>: supply a title for the top of each page. user: From the mapsecrets file - see config.html from the base documentation =head1 VERSION -$Id: freeside-receivables-report,v 1.2 2002-03-05 09:44:09 ivan Exp $ +$Id: freeside-receivables-report,v 1.6 2002-09-09 22:57:34 ivan Exp $ =head1 BUGS @@ -198,24 +207,11 @@ for more information regarding this license. L, config.html from the base documentation -=head1 HISTORY - -griff@aver-computer.com July 99 +=head1 AUTHOR -$Log: freeside-receivables-report,v $ -Revision 1.2 2002-03-05 09:44:09 ivan -yes i have crazy customers with 8-digit customer numbers - -Revision 1.1 2002/02/22 23:18:32 jeff -add some reporting features - -Revision 1.1 2000/09/20 19:25:19 jeff -local modifications - -Revision 1.1 2000/05/13 21:57:56 ivan -add print_batch script from Joel Griffiths +Jeff Finucane +based on print-batch by Joel Griffiths =cut -