send email on signup server signups (closes: Bug#386)
authorivan <ivan>
Sun, 7 Apr 2002 06:23:29 +0000 (06:23 +0000)
committerivan <ivan>
Sun, 7 Apr 2002 06:23:29 +0000 (06:23 +0000)
FS/FS/Conf.pm
FS/FS/cust_bill.pm
FS/FS/cust_pay.pm
fs_signup/fs_signup_server

index 6e58820..14dce1a 100644 (file)
@@ -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.',
index 2461e42..1f402fc 100644 (file)
@@ -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
 
index 421f020..ac60dc2 100644 (file)
@@ -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
 
index f3030e9..871bbdf 100755 (executable)
@@ -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;