RT#30613: Can't Send E-mail
authorJonathan Prykop <jonathan@freeside.biz>
Fri, 30 Jan 2015 00:00:36 +0000 (18:00 -0600)
committerJonathan Prykop <jonathan@freeside.biz>
Sat, 31 Jan 2015 05:10:18 +0000 (23:10 -0600)
13 files changed:
FS/FS/Conf.pm
FS/FS/Cron/agent_email.pm
FS/FS/Cron/upload.pm
FS/FS/cust_bill.pm
FS/FS/cust_credit.pm
FS/FS/cust_main.pm
FS/FS/cust_main/Billing_Realtime.pm
FS/FS/cust_pay.pm
FS/FS/cust_pkg.pm
FS/FS/msg_template.pm
FS/FS/pay_batch.pm
FS/FS/quotation.pm
FS/FS/upload_target.pm

index 688ee10..b7fb1cd 100644 (file)
@@ -592,6 +592,21 @@ sub config_items {
   ( @config_items, $self->_orbase_items(@_) );
 }
 
+=item invoice_from_full [ AGENTNUM ]
+
+Returns values of invoice_from and invoice_from_name, appropriately combined
+based on their current values.
+
+=cut
+
+sub invoice_from_full {
+  my ($self, $agentnum) = @_;
+  return $self->config('invoice_from_name', $agentnum ) ?
+         $self->config('invoice_from_name', $agentnum ) . ' <' .
+         $self->config('invoice_from', $agentnum ) . '>' :
+         $self->config('invoice_from', $agentnum );
+}
+
 =back
 
 =head1 SUBROUTINES
index 623b920..6bc1cc6 100644 (file)
@@ -29,10 +29,7 @@ sub agent_email {
     RT::ConnectToDatabase();
   }
 
-  my $from = $conf->config('invoice_from_name') ?
-             $conf->config('invoice_from_name') . ' <' . 
-             $conf->config('invoice_from') . '>' :
-             $conf->config('invoice_from');
+  my $from = $conf->invoice_from_full();
 
   my $outbuf = '';;
   my( $fs_interp, $rt_interp ) = mason_interps('standalone', 'outbuf'=>\$outbuf);
index fa1762f..6a4d153 100644 (file)
@@ -508,10 +508,7 @@ sub prepare_report {
 
   (
     to      => $to,
-    from    => $conf->config('invoice_from_name', $agentnum) ?
-               $conf->config('invoice_from_name', $agentnum) . ' <' . 
-               $conf->config('invoice_from', $agentnum) . '>' :
-               $conf->config('invoice_from', $agentnum),
+    from    => $conf->invoice_from_full($agentnum),
     subject => $subject,
     body    => $body,
   );
index 1c5ecf8..1af1028 100644 (file)
@@ -1092,10 +1092,7 @@ sub email {
 
   # this is where we set the From: address
   $from ||= $self->_agent_invoice_from ||    #XXX should go away
-            $conf->config('invoice_from_name', $self->cust_main->agentnum ) ?
-            $conf->config('invoice_from_name', $self->cust_main->agentnum ) . ' <' .
-            $conf->config('invoice_from', $self->cust_main->agentnum ) . '>' :
-            $conf->config('invoice_from', $self->cust_main->agentnum );
+            $conf->invoice_from_full( $self->cust_main->agentnum );
 
   my @invoicing_list = $self->cust_main->invoicing_list_emailonly;
 
index 59bd586..badb673 100644 (file)
@@ -248,10 +248,7 @@ sub delete {
     my $cust_main = $self->cust_main;
 
     my $error = send_email(
-      'from'    => $conf->config('invoice_from_name', $self->cust_main->agentnum) ?
-                   $conf->config('invoice_from_name', $self->cust_main->agentnum) . ' <' .
-                   $conf->config('invoice_from', $self->cust_main->agentnum) . '>' :
-                   $conf->config('invoice_from', $self->cust_main->agentnum),
+      'from'    => $conf->invoice_from_full($self->cust_main->agentnum),
                                  #invoice_from??? well as good as any
       'to'      => $conf->config('deletecredits'),
       'subject' => 'FREESIDE NOTIFICATION: Credit deleted',
index d8083bd..a633764 100644 (file)
@@ -4818,10 +4818,7 @@ sub notify {
 
   return unless $conf->exists($template);
 
-  my $from = $conf->config('invoice_from_name', $self->agentnum) ?
-             $conf->config('invoice_from_name', $self->agentnum) . ' <' .
-             $conf->config('invoice_from', $self->agentnum) . '>' :
-             $conf->config('invoice_from', $self->agentnum)
+  my $from = $conf->invoice_from_full($self->agentnum)
     if $conf->exists('invoice_from', $self->agentnum);
   $from = $options{from} if exists($options{from});
 
index f70bab2..d4bd1f3 100644 (file)
@@ -1107,10 +1107,7 @@ sub _realtime_bop_result {
         };
 
         my $error = send_email(
-          'from'    => $conf->config('invoice_from_name', $self->agentnum ) ?
-                       $conf->config('invoice_from_name', $self->agentnum ) . ' <' .
-                       $conf->config('invoice_from', $self->agentnum ) . '>' :
-                       $conf->config('invoice_from', $self->agentnum ),
+          'from'    => $conf->invoice_from_full( $self->agentnum ),
           'to'      => [ grep { $_ ne 'POST' } $self->invoicing_list ],
           'subject' => 'Your payment could not be processed',
           'body'    => [ $template->fill_in(HASH => $templ_hash) ],
index 45f9487..1e27851 100644 (file)
@@ -707,10 +707,7 @@ sub send_receipt {
         'msgtype' => 'receipt',
       };
       $error = $queue->insert(
-        'from'    => $conf->config('invoice_from_name', $cust_main->agentnum ) ?
-                     $conf->config('invoice_from_name', $cust_main->agentnum ) . ' <' .
-                     $conf->config('invoice_from', $cust_main->agentnum ) . '>' :
-                     $conf->config('invoice_from', $cust_main->agentnum ),
+        'from'    => $conf->invoice_from_full( $cust_main->agentnum ),
                                    #invoice_from??? well as good as any
         'to'      => \@invoicing_list,
         'subject' => 'Payment receipt',
index 55fa7a9..48cc187 100644 (file)
@@ -960,10 +960,7 @@ sub cancel {
     }
     else {
       $error = send_email(
-        'from'    => $conf->config('invoice_from_name', $self->cust_main->agentnum) ?
-                     $conf->config('invoice_from_name', $self->cust_main->agentnum) . ' <' .
-                     $conf->config('invoice_from', $self->cust_main->agentnum) . '>' :
-                     $conf->config('invoice_from', $self->cust_main->agentnum),
+        'from'    => $conf->invoice_from_full( $self->cust_main->agentnum ),
         'to'      => \@invoicing_list,
         'subject' => ( $conf->config('cancelsubject') || 'Cancellation Notice' ),
         'body'    => [ map "$_\n", $conf->config('cancelmessage') ],
index a2682eb..2826086 100644 (file)
@@ -397,10 +397,7 @@ sub prepare {
       $from_addr = scalar( $conf->config($opt{'from_config'}, 
                                          $cust_main->agentnum) );
     }
-    $from_addr ||= $conf->config('invoice_from_name', $cust_main->agentnum) ?
-                   $conf->config('invoice_from_name', $cust_main->agentnum) . ' <' .
-                   $conf->config('invoice_from', $cust_main->agentnum) . '>' :
-                   $conf->config('invoice_from', $cust_main->agentnum);
+    $from_addr ||= $conf->invoice_from_full($cust_main->agentnum);
   }
 #  my @cust_msg = ();
 #  if ( $conf->exists('log_sent_mail') and !$opt{'preview'} ) {
index fe03bd0..55e4d3f 100644 (file)
@@ -764,10 +764,7 @@ sub import_from_gateway {
       my $body = "Import from gateway ".$gateway->label."\n".$error_text;
       send_email(
         to      => $mail_on_error,
-        from    => $conf->config('invoice_from_name') ?
-                   $conf->config('invoice_from_name') . ' <' .
-                   $conf->config('invoice_from') . '>' :
-                   $conf->config('invoice_from'),
+        from    => $conf->invoice_from_full(),
         subject => $subject,
         body    => $body,
       );
index e24f1dd..f98e3b4 100644 (file)
@@ -198,10 +198,7 @@ sub email {
 
   # this is where we set the From: address
   $from ||= $conf->config('quotation_from', $self->cust_or_prospect->agentnum )
-        || ($conf->config('invoice_from_name', $self->cust_or_prospect->agentnum ) ?
-            $conf->config('invoice_from_name', $self->cust_or_prospect->agentnum ) . ' <' .
-            $conf->config('invoice_from', $self->cust_or_prospect->agentnum ) . '>' :
-            $conf->config('invoice_from', $self->cust_or_prospect->agentnum ));
+        ||  $conf->invoice_from_full( $self->cust_or_prospect->agentnum );
   $self->SUPER::email( {
     'from' => $from,
     %$opt,
index 73d2a04..af2dcb1 100644 (file)
@@ -163,10 +163,7 @@ sub put {
     # (maybe use only the raw content, so that we don't have to supply a 
     # customer for substitutions? ewww.)
     my %message = (
-      'from'          => $conf->config('invoice_from_name') ?
-                         $conf->config('invoice_from_name') . ' <' .
-                         $conf->config('invoice_from') . '>' :
-                         $conf->config('invoice_from'),
+      'from'          => $conf->invoice_from_full(),
       'to'            => $to,
       'subject'       => $self->subject,
       'nobody'        => 1,