X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-credit-report;h=7699daf4d63f13d1e2e3c83e9633ea4cab07bbda;hp=c73988321f616a4f90e1c59f0765be94bb32b544;hb=3e2e5fecb9ef3cf39a6ac098aacb76763edd3938;hpb=64ed7b8c527bcf3e689a3f61fcdb8b4185460936 diff --git a/FS/bin/freeside-credit-report b/FS/bin/freeside-credit-report index c73988321..7699daf4d 100755 --- a/FS/bin/freeside-credit-report +++ b/FS/bin/freeside-credit-report @@ -6,16 +6,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_credit; -# 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 $opt_s $opt_f $report_lines $report_template @buf); +use vars qw($opt_v $opt_p $opt_m $opt_e $opt_t $opt_s $opt_f $report_lines $report_template @buf $header); getopts("vpmef:s:"); #switches #we're at now now (and later). @@ -42,6 +43,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; @@ -73,14 +77,14 @@ if ($lpr && $main::opt_p) if ($email && $main::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: $!"; } @@ -190,7 +199,7 @@ user: From the mapsecrets file - see config.html from the base documentation =head1 VERSION -$Id: freeside-credit-report,v 1.3 2002-03-06 00:17:32 ivan Exp $ +$Id: freeside-credit-report,v 1.4 2002-03-07 19:50:24 jeff Exp $ =head1 BUGS