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).
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;
if ($email && $opt_m)
{
- open (MAIL, "|$mail_program");
- print MAIL <<END
-To: $email
-From: Account Processor
-Subject: Receivables
-
-
-END
+ $ENV{MAILADDRESS} = $mail_sender;
+ $header = new Mail::Header ( [
+ "From: Account Processor",
+ "To: $email",
+ "Sender: $mail_sender",
+ "Reply-To: $mail_sender",
+ "Subject: Receivables",
+ ] );
}
my $total = 0;
}
if($email && $opt_m)
{
- print MAIL map "$_\n", @report;
- close MAIL || die "Could not close printer: $email\n";
+ my $message = new Mail::Internet (
+ 'Header' => $header,
+ 'Body' => [ (@report) ],
+ );
+ $!=0;
+ $message->smtpsend( Host => "$smtpmachine" )
+ or die "can't send report to $email via $smtpmachine: $!";
}
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.3 2002-03-05 23:13:23 jeff Exp $
+$Id: freeside-receivables-report,v 1.5 2002-03-07 19:50:24 jeff Exp $
=head1 BUGS
L<FS::cust_main>, config.html from the base documentation
-=head1 HISTORY
+=head1 AUTHOR
-griff@aver-computer.com July 99
-
-$Log: freeside-receivables-report,v $
-Revision 1.3 2002-03-05 23:13:23 jeff
-consistency is nice
+Jeff Finucane <jeff@cmh.net>
+based on print-batch by Joel Griffiths <griff@aver-computer.com>
=cut
-