projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
64ed7b8
)
less shelling, more perly - abolish some pipes to sendmail
author
jeff
<jeff>
Thu, 7 Mar 2002 19:50:24 +0000
(19:50 +0000)
committer
jeff
<jeff>
Thu, 7 Mar 2002 19:50:24 +0000
(19:50 +0000)
FS/bin/freeside-cc-receipts-report
patch
|
blob
|
history
FS/bin/freeside-credit-report
patch
|
blob
|
history
FS/bin/freeside-expiration-alerter
patch
|
blob
|
history
FS/bin/freeside-receivables-report
patch
|
blob
|
history
FS/bin/freeside-tax-report
patch
|
blob
|
history
diff --git
a/FS/bin/freeside-cc-receipts-report
b/FS/bin/freeside-cc-receipts-report
index
48075a8
..
06e3aba
100755
(executable)
--- a/
FS/bin/freeside-cc-receipts-report
+++ b/
FS/bin/freeside-cc-receipts-report
@@
-6,17
+6,18
@@
use Date::Parse;
use Time::Local;
use Getopt::Std;
use Text::Template;
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 qsearchs);
use FS::cust_pay;
use FS::cust_pay_batch;
use FS::Conf;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch qsearchs);
use FS::cust_pay;
use FS::cust_pay_batch;
-# Set the mail program
-my $mail_program = "/usr/sbin/sendmail -t -n";
&untaint_argv; #what it sounds like (eww)
&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).
getopts("vpmef:s:"); #switches
#we're at now now (and later).
@@
-43,6
+44,9
@@
adminsuidsetup $user;
my $conf = new FS::Conf;
my $lpr = $conf->config('lpr');
my $email = $conf->config('email');
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;
my @report_template = $conf->config('report_template')
or die "cannot load config file report_template";
$report_lines = 0;
@@
-74,14
+78,14
@@
if ($lpr && $main::opt_p)
if ($email && $main::opt_m)
{
if ($email && $main::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: Credit Card Receipts",
+ ] );
}
my $uninvoiced = 0;
}
my $uninvoiced = 0;
@@
-189,8
+193,13
@@
if($lpr && $opt_p)
}
if($email && $opt_m)
{
}
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: $!";
}
}
@@
-236,7
+245,7
@@
user: From the mapsecrets file - see config.html from the base documentation
=head1 VERSION
=head1 VERSION
-$Id: freeside-cc-receipts-report,v 1.
3 2002-03-06 00:17:32 ivan
Exp $
+$Id: freeside-cc-receipts-report,v 1.
4 2002-03-07 19:50:23 jeff
Exp $
=head1 BUGS
=head1 BUGS
diff --git
a/FS/bin/freeside-credit-report
b/FS/bin/freeside-credit-report
index
c739883
..
7699daf
100755
(executable)
--- 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 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;
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)
&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).
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 $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;
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)
{
if ($email && $main::opt_m)
{
-
open (MAIL, "|$mail_program")
;
- print MAIL <<END
-To: $email
-From: Account Processor
-Subject: In House Credits
-
-
-END
+
$ENV{MAILADDRESS} = $mail_sender
;
+ $header = new Mail::Header ( [
+ "From: Account Processor",
+ "To: $email",
+ "Sender: $mail_sender",
+ "Reply-To: $mail_sender",
+ "Subject: In House Credits",
+ ] );
}
my $uninvoiced = 0;
}
my $uninvoiced = 0;
@@
-143,8
+147,13
@@
if($lpr && $opt_p)
}
if($email && $opt_m)
{
}
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: $!";
}
}
@@
-190,7
+199,7
@@
user: From the mapsecrets file - see config.html from the base documentation
=head1 VERSION
=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
=head1 BUGS
diff --git
a/FS/bin/freeside-expiration-alerter
b/FS/bin/freeside-expiration-alerter
index
c3dc37b
..
365b964
100755
(executable)
--- a/
FS/bin/freeside-expiration-alerter
+++ b/
FS/bin/freeside-expiration-alerter
@@
-5,12
+5,15
@@
use Date::Format;
use Time::Local;
use Text::Template;
use Getopt::Std;
use Time::Local;
use Text::Template;
use Getopt::Std;
+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;
use FS::Conf;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch);
use FS::cust_main;
-use vars qw($smtpmachine);
+use vars qw($smtpmachine
@body
);
#hush, perl!
$FS::alerter::_template::first = "";
#hush, perl!
$FS::alerter::_template::first = "";
@@
-20,9
+23,8
@@
$FS::alerter::_template::payby = "";
$FS::alerter::_template::expdate = "";
# Set the mail program and other variables
$FS::alerter::_template::expdate = "";
# Set the mail program and other variables
-my $mail_program = "/usr/sbin/sendmail -t -n";
-my $mail_sender = "billing\@mydomain.tld";
-my $default_mail_recipient = "postmaster";
+my $mail_sender = "billing\@mydomain.tld"; # or invoice_from if available
+my $failure_recipient = "postmaster"; # or invoice_from if available
my $warning_time = 30 * 24 * 60 * 60;
my $urgent_time = 15 * 24 * 60 * 60;
my $panic_time = 5 * 24 * 60 * 60;
my $warning_time = 30 * 24 * 60 * 60;
my $urgent_time = 15 * 24 * 60 * 60;
my $panic_time = 5 * 24 * 60 * 60;
@@
-45,6
+47,11
@@
adminsuidsetup $user;
# Get the needed configuration files
my $conf = new FS::Conf;
$smtpmachine = $conf->config('smtpmachine');
# Get the needed configuration files
my $conf = new FS::Conf;
$smtpmachine = $conf->config('smtpmachine');
+$mail_sender = $conf->config('invoice_from')
+ if $conf->exists('invoice_from');
+$failure_recipient = $conf->config('invoice_from')
+ if $conf->exists('invoice_from');
+
my(@customers)=qsearch('cust_main',{});
if (scalar(@customers) == 0)
my(@customers)=qsearch('cust_main',{});
if (scalar(@customers) == 0)
@@
-52,18
+59,16
@@
if (scalar(@customers) == 0)
exit 1;
}
exit 1;
}
-# Open email pipe
-
-open (MAIL, "|$mail_program");
-print MAIL <<END
-To: $default_mail_recipient
-From: Account Processor
-Subject: Unnotified Billing Arrangement Expirations
-
+# Prepare for sending email
-END
-
-;
+$ENV{MAILADDRESS} = $mail_sender;
+my $header = new Mail::Header ( [
+ "From: Account Processor",
+ "To: $failure_recipient",
+ "Sender: $mail_sender",
+ "Reply-To: $mail_sender",
+ "Subject: Unnotified Billing Arrangement Expirations",
+] );
my @alerter_template = $conf->config('alerter_template')
or die "cannot load config file alerter_template";
my @alerter_template = $conf->config('alerter_template')
or die "cannot load config file alerter_template";
@@
-109,8
+114,6
@@
foreach my $customer (@customers)
if (scalar(@packages) != 0) {
my @invoicing_list = $customer->invoicing_list;
if ( grep { $_ ne 'POST' } @invoicing_list ) {
if (scalar(@packages) != 0) {
my @invoicing_list = $customer->invoicing_list;
if ( grep { $_ ne 'POST' } @invoicing_list ) {
- $ENV{SMTPHOSTS} = $smtpmachine;
- $ENV{MAILADDRESS} = $mail_sender;
my $header = new Mail::Header ( [
"From: $mail_sender",
"To: ". join(', ', grep { $_ ne 'POST' } @invoicing_list ),
my $header = new Mail::Header ( [
"From: $mail_sender",
"To: ". join(', ', grep { $_ ne 'POST' } @invoicing_list ),
@@
-137,10
+140,12
@@
foreach my $customer (@customers)
'Header' => $header,
'Body' => [ $alerter->fill_in( PACKAGE => 'FS::alerter::_template' ) ],
);
'Header' => $header,
'Body' => [ $alerter->fill_in( PACKAGE => 'FS::alerter::_template' ) ],
);
- $message->smtpsend or die "Can't send invoice email!: $!"; #die? warn?
+ $!=0;
+ $message->smtpsend( Host => $smtpmachine )
+ or die "Can't send expiration email!: $!"; #die? warn?
} elsif ( ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list ) {
} elsif ( ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list ) {
- p
rintf(MAIL qq{%5d %-32.32s %4s %10s %12s %12s\n
},
+ p
ush @body, sprintf(qq{%5d %-32.32s %4s %10s %12s %12s
},
$custnum,
$first . " " . $last . " " . $company,
$payby,
$custnum,
$first . " " . $last . " " . $company,
$payby,
@@
-152,9
+157,18
@@
foreach my $customer (@customers)
}
}
}
}
-# Now I need to close EMAIL
-close MAIL || die "Could not close printer: $default_mail_recipient\n";
-
+# Now I need to send EMAIL
+if (scalar(@body)) {
+ my $message = new Mail::Internet (
+ 'Header' => $header,
+ 'Body' => [ (@body) ],
+ );
+ $!=0;
+ $message->smtpsend( Host => $smtpmachine )
+ or $message->smtpsend( Host => $smtpmachine, Debug => 1 )
+ or return "can't send alerter failure email to $failure_recipient".
+ " via server $smtpmachine with SMTP: $!";
+}
# subroutines
sub untaint_argv {
# subroutines
sub untaint_argv {
@@
-185,7
+199,7
@@
user: From the mapsecrets file - see config.html from the base documentation
=head1 VERSION
=head1 VERSION
-$Id: freeside-expiration-alerter,v 1.
1 2002-03-06 22:44:13
jeff Exp $
+$Id: freeside-expiration-alerter,v 1.
2 2002-03-07 19:50:24
jeff Exp $
=head1 BUGS
=head1 BUGS
diff --git
a/FS/bin/freeside-receivables-report
b/FS/bin/freeside-receivables-report
index
781e23b
..
b5a4903
100755
(executable)
--- 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 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;
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)
&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).
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 $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;
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)
{
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;
}
my $total = 0;
@@
-139,8
+143,13
@@
if($lpr && $opt_p)
}
if($email && $opt_m)
{
}
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: $!";
}
}
@@
-183,7
+192,7
@@
user: From the mapsecrets file - see config.html from the base documentation
=head1 VERSION
=head1 VERSION
-$Id: freeside-receivables-report,v 1.
4 2002-03-06 00:17:32 ivan
Exp $
+$Id: freeside-receivables-report,v 1.
5 2002-03-07 19:50:24 jeff
Exp $
=head1 BUGS
=head1 BUGS
diff --git
a/FS/bin/freeside-tax-report
b/FS/bin/freeside-tax-report
index
ec4b99f
..
8d50213
100755
(executable)
--- a/
FS/bin/freeside-tax-report
+++ b/
FS/bin/freeside-tax-report
@@
-6,6
+6,9
@@
use Date::Parse;
use Time::Local;
use Getopt::Std;
use Text::Template;
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::Conf;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch);
@@
-13,11
+16,9
@@
use FS::cust_bill;
use FS::cust_bill_pay;
use FS::cust_pay;
use FS::cust_bill_pay;
use FS::cust_pay;
-# Set the mail program
-my $mail_program = "/usr/sbin/sendmail -t -n";
&untaint_argv; #what it sounds like (eww)
&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).
getopts("vpmef:s:"); #switches
#we're at now now (and later).
@@
-44,6
+45,9
@@
adminsuidsetup $user;
my $conf = new FS::Conf;
my $lpr = $conf->config('lpr');
my $email = $conf->config('email');
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;
my @report_template = $conf->config('report_template')
or die "cannot load config file report_template";
$report_lines = 0;
@@
-75,14
+79,14
@@
if ($lpr && $main::opt_p)
if ($email && $main::opt_m)
{
if ($email && $main::opt_m)
{
-
open (MAIL, "|$mail_program")
;
- print MAIL <<END
-To: $email
-From: Account Processor
-Subject: Sales Taxes Invoiced
-
-
-END
+
$ENV{MAILADDRESS} = $mail_sender
;
+ $header = new Mail::Header ( [
+ "From: Account Processor",
+ "To: $email",
+ "Sender: $mail_sender",
+ "Reply-To: $mail_sender",
+ "Subject: Sales Taxes Invoiced",
+ ] );
}
my $comped = 0;
}
my $comped = 0;
@@
-211,8
+215,13
@@
if($lpr && $opt_p)
}
if($email && $opt_m)
{
}
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: $!";
}
}
@@
-258,7
+267,7
@@
user: From the mapsecrets file - see config.html from the base documentation
=head1 VERSION
=head1 VERSION
-$Id: freeside-tax-report,v 1.
3 2002-03-06 00:17:32 ivan
Exp $
+$Id: freeside-tax-report,v 1.
4 2002-03-07 19:50:24 jeff
Exp $
=head1 BUGS
=head1 BUGS