From 17544eafba683f48cdc64fef09745d17be9b088a Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Apr 2002 06:23:29 +0000 Subject: [PATCH] send email on signup server signups (closes: Bug#386) --- FS/FS/Conf.pm | 8 ++++++++ FS/FS/cust_bill.pm | 4 ++-- FS/FS/cust_pay.pm | 6 +++--- fs_signup/fs_signup_server | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 5 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index 6e588208a..14dce1abf 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -874,6 +874,14 @@ httemplate/docs/config.html }, { + 'key' => 'signup_server-email', + 'section' => '', + 'description' => 'Comma-separated list of email addresses to receive notification of signups via the signup server.', + 'type' => 'text', + }, + + + { 'key' => 'show-msgcat-codes', 'section' => 'UI', 'description' => 'Show msgcat codes in error messages. Turn this option on before reporting errors to the mailing list.', diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm index 2461e42f1..1f402fca4 100644 --- a/FS/FS/cust_bill.pm +++ b/FS/FS/cust_bill.pm @@ -373,7 +373,7 @@ sub send { #my @print_text = $cust_bill->print_text; #( date ) my @invoicing_list = $self->cust_main->invoicing_list; if ( grep { $_ ne 'POST' } @invoicing_list ) { #email invoice - #false laziness w/FS::cust_pay::delete + #false laziness w/FS::cust_pay::delete & fs_signup_server #$ENV{SMTPHOSTS} = $smtpmachine; $ENV{MAILADDRESS} = $invoice_from; my $header = new Mail::Header ( [ @@ -900,7 +900,7 @@ sub print_text { =head1 VERSION -$Id: cust_bill.pm,v 1.25 2002-04-06 22:32:43 ivan Exp $ +$Id: cust_bill.pm,v 1.26 2002-04-07 06:23:29 ivan Exp $ =head1 BUGS diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm index 421f0200e..ac60dc242 100644 --- a/FS/FS/cust_pay.pm +++ b/FS/FS/cust_pay.pm @@ -264,8 +264,8 @@ sub delete { if ( $conf->config('deletepayments') ne '' ) { my $cust_main = qsearchs('cust_main',{ 'custnum' => $self->custnum }); - #false laziness w/FS::cust_bill::send - $ENV{MAILADDRESS} = $conf->config('invoice_from'); #??? well as good as any + #false laziness w/FS::cust_bill::send & fs_signup_server + $ENV{MAILADDRESS} = $invoice_from; #??? well as good as any my $header = new Mail::Header ( [ "From: $invoice_from", "To: ". $conf->config('deletepayments'), @@ -405,7 +405,7 @@ sub unapplied { =head1 VERSION -$Id: cust_pay.pm,v 1.18 2002-03-18 19:49:10 ivan Exp $ +$Id: cust_pay.pm,v 1.19 2002-04-07 06:23:29 ivan Exp $ =head1 BUGS diff --git a/fs_signup/fs_signup_server b/fs_signup/fs_signup_server index f3030e9ae..871bbdf1b 100755 --- a/fs_signup/fs_signup_server +++ b/fs_signup/fs_signup_server @@ -26,6 +26,7 @@ my $conf = new FS::Conf; #my @payby = qw(CARD PREPAY); my @payby = $conf->config('signup_server-payby'); +my $smtpmachine = $conf->config('smtpmachine'); my $machine = shift or die &usage; @@ -154,6 +155,43 @@ while (1) { warn "[fs_signup_server] Sending results...\n" if $Debug; print $writer $error, "\n"; + if ( $error && $conf->config('signup_server-email') ) { + warn "[fs_signup_server] Sending email...\n" if $Debug; + + #false laziness w/FS::cust_bill::send & FS::cust_pay::delete + use Mail::Header; + use Mail::Internet; + my $from = $conf->config('invoice_from'); #??? as good as any + $ENV{MAILADDRESS} = $from; + my $header = new Mail::Header ( [ + "From: $from", + "To: ". $conf->config('signup_server-email'), + "Sender: $from", + "Reply-To: $from", + "Date: ". time2str("%a, %d %b %Y %X %z", time), + "Subject: FREESIDE NOTIFICATION: Signup Server", + ] ); + my $message = new Mail::Internet ( + 'Header' => $header, + 'Body' => [ + "This is an automatic message from your Freeside installation\n", + "informing you a customer has signed up via the signup server:\n", + "\n", + 'custnum: '. $cust_main->custnum. "\n", + 'Name : '. $cust_main->last. ", ". $cust_main->first. "\n", + 'Agent : '. $cust_main->agent->agent. "\n", + "\n", + ], + ); + $!=0; + $message->smtpsend( Host => $smtpmachine ) + or $message->smtpsend( Host => $smtpmachine, Debug => 1 ) + or warn "[fs_signup_server] can't send email to ". + $conf->config('signup_server-email'). + " via server $smtpmachine with SMTP: $!"; + #end-of-send mail + } + } close $writer; close $reader; -- 2.11.0