[freeside-commits] branch FREESIDE_3_BRANCH updated. b403c08477da81266b789e103767f096daff4828

Jonathan Prykop jonathan at 420.am
Mon Feb 2 13:17:24 PST 2015


The branch, FREESIDE_3_BRANCH has been updated
       via  b403c08477da81266b789e103767f096daff4828 (commit)
       via  973d5dd654ea23dea3ff185e157a404556815ccb (commit)
       via  fcb0e3c1cb7567c7ce2c24a367c304b9a1e356f3 (commit)
       via  46ca67d352957406bedb44680a9266e20f3cfd2c (commit)
       via  7fe9f776655a9a7fc3b93b4f0e06c8b8193834b6 (commit)
      from  80a28e539bd4ad11a309e5f98402beea648fee67 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b403c08477da81266b789e103767f096daff4828
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Sat Jan 31 00:27:01 2015 -0600

    #30613 Can't Send E-mail (Additional fixes for upgrade)

diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm
index 9187cab..3146222 100644
--- a/FS/FS/Upgrade.pm
+++ b/FS/FS/Upgrade.pm
@@ -70,7 +70,7 @@ sub upgrade_config {
 
   upgrade_invoice_from($conf);
   foreach my $agent (@agents) {
-    upgrade_invoice_from($conf,$agent->agentnum);
+    upgrade_invoice_from($conf,$agent->agentnum,1);
   }
 
   my $DIST_CONF = '/usr/local/etc/freeside/default_conf/';#DIST_CONF in Makefile
@@ -167,10 +167,10 @@ sub upgrade_overlimit_groups {
 }
 
 sub upgrade_invoice_from {
-  my ($conf, $agentnum) = @_;
+  my ($conf, $agentnum, $agentonly) = @_;
   if (
-      (!$conf->config('invoice_from_name',$agentnum)) && 
-      ($conf->config('invoice_from',$agentnum) =~ /\<(.*)\>/)
+      (!$conf->exists('invoice_from_name',$agentnum,$agentonly)) && 
+      ($conf->config('invoice_from',$agentnum,$agentonly) =~ /\<(.*)\>/)
   ) {
     my $realemail = $1;
     $realemail =~ s/^\s*//; # remove leading spaces

commit 973d5dd654ea23dea3ff185e157a404556815ccb
Merge: fcb0e3c 80a28e5
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Mon Feb 2 15:04:02 2015 -0600

    Merge branch 'FREESIDE_3_BRANCH' of git.freeside.biz:/home/git/freeside into FREESIDE_3_BRANCH


commit fcb0e3c1cb7567c7ce2c24a367c304b9a1e356f3
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Thu Jan 29 19:39:01 2015 -0600

    RT#30613: Can't Send E-mail [Upgrade improvements]

diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm
index 0dab2f7..9187cab 100644
--- a/FS/FS/Upgrade.pm
+++ b/FS/FS/Upgrade.pm
@@ -46,22 +46,6 @@ sub upgrade_config {
 
   my $conf = new FS::Conf;
 
-  if ($conf->config('invoice_from') =~ /\<(.*)\>/) {
-    my $realemail = $1;
-    $realemail =~ s/^\s*//; # remove leading spaces
-    $realemail =~ s/\s*$//; # remove trailing spaces
-    my $realname = $conf->config('invoice_from');
-    $realname =~ s/\<.*\>//; # remove email address
-    $realname =~ s/^\s*//; # remove leading spaces
-    $realname =~ s/\s*$//; # remove trailing spaces
-    # properly quote names that contain punctuation
-    if (($realname =~ /[^[:alnum:][:space:]]/) && ($realname !~ /^\".*\"$/)) {
-      $realname = '"' . $realname . '"';
-    }
-    $conf->set('invoice_from_name', $realname);
-    $conf->set('invoice_from', $realemail);
-  }
-
   $conf->touch('payment_receipt')
     if $conf->exists('payment_receipt_email')
     || $conf->config('payment_receipt_msgnum');
@@ -79,8 +63,15 @@ sub upgrade_config {
     }
   }
 
+  my @agents = qsearch('agent', {});
+
   upgrade_overlimit_groups($conf);
-  map { upgrade_overlimit_groups($conf,$_->agentnum) } qsearch('agent', {});
+  map { upgrade_overlimit_groups($conf,$_->agentnum) } @agents;
+
+  upgrade_invoice_from($conf);
+  foreach my $agent (@agents) {
+    upgrade_invoice_from($conf,$agent->agentnum);
+  }
 
   my $DIST_CONF = '/usr/local/etc/freeside/default_conf/';#DIST_CONF in Makefile
   $conf->set($_, scalar(read_file( "$DIST_CONF/$_" )) )
@@ -175,6 +166,28 @@ sub upgrade_overlimit_groups {
     }
 }
 
+sub upgrade_invoice_from {
+  my ($conf, $agentnum) = @_;
+  if (
+      (!$conf->config('invoice_from_name',$agentnum)) && 
+      ($conf->config('invoice_from',$agentnum) =~ /\<(.*)\>/)
+  ) {
+    my $realemail = $1;
+    $realemail =~ s/^\s*//; # remove leading spaces
+    $realemail =~ s/\s*$//; # remove trailing spaces
+    my $realname = $conf->config('invoice_from',$agentnum);
+    $realname =~ s/\<.*\>//; # remove email address
+    $realname =~ s/^\s*//; # remove leading spaces
+    $realname =~ s/\s*$//; # remove trailing spaces
+    # properly quote names that contain punctuation
+    if (($realname =~ /[^[:alnum:][:space:]]/) && ($realname !~ /^\".*\"$/)) {
+      $realname = '"' . $realname . '"';
+    }
+    $conf->set('invoice_from_name', $realname, $agentnum);
+    $conf->set('invoice_from', $realemail, $agentnum);
+  }
+}
+
 =item upgrade
 
 =cut

commit 46ca67d352957406bedb44680a9266e20f3cfd2c
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Thu Jan 29 18:00:36 2015 -0600

    RT#30613: Can't Send E-mail

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index 688ee10..b7fb1cd 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -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
diff --git a/FS/FS/Cron/agent_email.pm b/FS/FS/Cron/agent_email.pm
index 623b920..6bc1cc6 100644
--- a/FS/FS/Cron/agent_email.pm
+++ b/FS/FS/Cron/agent_email.pm
@@ -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);
diff --git a/FS/FS/Cron/upload.pm b/FS/FS/Cron/upload.pm
index fa1762f..6a4d153 100644
--- a/FS/FS/Cron/upload.pm
+++ b/FS/FS/Cron/upload.pm
@@ -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,
   );
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 1c5ecf8..1af1028 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -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;
 
diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm
index 59bd586..badb673 100644
--- a/FS/FS/cust_credit.pm
+++ b/FS/FS/cust_credit.pm
@@ -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',
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index d8083bd..a633764 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -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});
 
diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index f70bab2..d4bd1f3 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -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) ],
diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index 45f9487..1e27851 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -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',
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 55fa7a9..48cc187 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -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') ],
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
index a2682eb..2826086 100644
--- a/FS/FS/msg_template.pm
+++ b/FS/FS/msg_template.pm
@@ -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'} ) {
diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm
index fe03bd0..55e4d3f 100644
--- a/FS/FS/pay_batch.pm
+++ b/FS/FS/pay_batch.pm
@@ -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,
       );
diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm
index e24f1dd..f98e3b4 100644
--- a/FS/FS/quotation.pm
+++ b/FS/FS/quotation.pm
@@ -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,
diff --git a/FS/FS/upload_target.pm b/FS/FS/upload_target.pm
index 73d2a04..af2dcb1 100644
--- a/FS/FS/upload_target.pm
+++ b/FS/FS/upload_target.pm
@@ -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,

commit 7fe9f776655a9a7fc3b93b4f0e06c8b8193834b6
Author: Jonathan Prykop <jonathan at freeside.biz>
Date:   Tue Jan 27 16:25:18 2015 -0600

    RT#30613: Can't Send E-mail

diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index ac366d9..688ee10 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -1233,9 +1233,24 @@ sub reason_type_options {
   {
     'key'         => 'invoice_from',
     'section'     => 'required',
-    'description' => 'Return address on email invoices',
+    'description' => 'Return address on email invoices (address only, see invoice_from_name)',
     'type'        => 'text',
     'per_agent'   => 1,
+    'validate'    => sub { $_[0] =~
+                             /^[^@]+\@[[:alnum:]-]+(\.[[:alnum:]-]+)+$/
+                             ? '' : 'Invalid email address';
+                         }
+  },
+
+  {
+    'key'         => 'invoice_from_name',
+    'section'     => 'invoicing',
+    'description' => 'Return name on email invoices (set address in invoice_from)',
+    'type'        => 'text',
+    'per_agent'   => 1,
+    'validate'    => sub { (($_[0] =~ /[^[:alnum:][:space:]]/) && ($_[0] !~ /^\".*\"$/))
+                           ? 'Invalid name.  Use quotation marks around names that contain punctuation.'
+                           : '' }
   },
 
   {
diff --git a/FS/FS/Cron/agent_email.pm b/FS/FS/Cron/agent_email.pm
index 992aa35..623b920 100644
--- a/FS/FS/Cron/agent_email.pm
+++ b/FS/FS/Cron/agent_email.pm
@@ -29,7 +29,10 @@ sub agent_email {
     RT::ConnectToDatabase();
   }
 
-  my $from = $conf->config('invoice_from');
+  my $from = $conf->config('invoice_from_name') ?
+             $conf->config('invoice_from_name') . ' <' . 
+             $conf->config('invoice_from') . '>' :
+             $conf->config('invoice_from');
 
   my $outbuf = '';;
   my( $fs_interp, $rt_interp ) = mason_interps('standalone', 'outbuf'=>\$outbuf);
diff --git a/FS/FS/Cron/upload.pm b/FS/FS/Cron/upload.pm
index 03ed366..fa1762f 100644
--- a/FS/FS/Cron/upload.pm
+++ b/FS/FS/Cron/upload.pm
@@ -508,7 +508,10 @@ sub prepare_report {
 
   (
     to      => $to,
-    from    => $conf->config('invoice_from', $agentnum),
+    from    => $conf->config('invoice_from_name', $agentnum) ?
+               $conf->config('invoice_from_name', $agentnum) . ' <' . 
+               $conf->config('invoice_from', $agentnum) . '>' :
+               $conf->config('invoice_from', $agentnum),
     subject => $subject,
     body    => $body,
   );
diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm
index dbac17e..0dab2f7 100644
--- a/FS/FS/Upgrade.pm
+++ b/FS/FS/Upgrade.pm
@@ -46,6 +46,22 @@ sub upgrade_config {
 
   my $conf = new FS::Conf;
 
+  if ($conf->config('invoice_from') =~ /\<(.*)\>/) {
+    my $realemail = $1;
+    $realemail =~ s/^\s*//; # remove leading spaces
+    $realemail =~ s/\s*$//; # remove trailing spaces
+    my $realname = $conf->config('invoice_from');
+    $realname =~ s/\<.*\>//; # remove email address
+    $realname =~ s/^\s*//; # remove leading spaces
+    $realname =~ s/\s*$//; # remove trailing spaces
+    # properly quote names that contain punctuation
+    if (($realname =~ /[^[:alnum:][:space:]]/) && ($realname !~ /^\".*\"$/)) {
+      $realname = '"' . $realname . '"';
+    }
+    $conf->set('invoice_from_name', $realname);
+    $conf->set('invoice_from', $realemail);
+  }
+
   $conf->touch('payment_receipt')
     if $conf->exists('payment_receipt_email')
     || $conf->config('payment_receipt_msgnum');
diff --git a/FS/FS/cust_bill.pm b/FS/FS/cust_bill.pm
index 7204821..1c5ecf8 100644
--- a/FS/FS/cust_bill.pm
+++ b/FS/FS/cust_bill.pm
@@ -1092,6 +1092,9 @@ 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 );
 
   my @invoicing_list = $self->cust_main->invoicing_list_emailonly;
diff --git a/FS/FS/cust_credit.pm b/FS/FS/cust_credit.pm
index d46c431..59bd586 100644
--- a/FS/FS/cust_credit.pm
+++ b/FS/FS/cust_credit.pm
@@ -248,7 +248,10 @@ sub delete {
     my $cust_main = $self->cust_main;
 
     my $error = send_email(
-      'from'    => $conf->config('invoice_from', $self->cust_main->agentnum),
+      '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),
                                  #invoice_from??? well as good as any
       'to'      => $conf->config('deletecredits'),
       'subject' => 'FREESIDE NOTIFICATION: Credit deleted',
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index b43d7e3..d8083bd 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -4818,7 +4818,10 @@ sub notify {
 
   return unless $conf->exists($template);
 
-  my $from = $conf->config('invoice_from', $self->agentnum)
+  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)
     if $conf->exists('invoice_from', $self->agentnum);
   $from = $options{from} if exists($options{from});
 
diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm
index a0b32ed..f70bab2 100644
--- a/FS/FS/cust_main/Billing_Realtime.pm
+++ b/FS/FS/cust_main/Billing_Realtime.pm
@@ -1107,7 +1107,10 @@ sub _realtime_bop_result {
         };
 
         my $error = send_email(
-          'from'    => $conf->config('invoice_from', $self->agentnum ),
+          '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 ),
           'to'      => [ grep { $_ ne 'POST' } $self->invoicing_list ],
           'subject' => 'Your payment could not be processed',
           'body'    => [ $template->fill_in(HASH => $templ_hash) ],
diff --git a/FS/FS/cust_pay.pm b/FS/FS/cust_pay.pm
index 01736f7..45f9487 100644
--- a/FS/FS/cust_pay.pm
+++ b/FS/FS/cust_pay.pm
@@ -707,7 +707,10 @@ sub send_receipt {
         'msgtype' => 'receipt',
       };
       $error = $queue->insert(
-        'from'    => $conf->config('invoice_from', $cust_main->agentnum),
+        '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 ),
                                    #invoice_from??? well as good as any
         'to'      => \@invoicing_list,
         'subject' => 'Payment receipt',
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index de9aa08..55fa7a9 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -960,7 +960,10 @@ sub cancel {
     }
     else {
       $error = send_email(
-        'from'    => $conf->config('invoice_from', $self->cust_main->agentnum),
+        '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),
         'to'      => \@invoicing_list,
         'subject' => ( $conf->config('cancelsubject') || 'Cancellation Notice' ),
         'body'    => [ map "$_\n", $conf->config('cancelmessage') ],
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
index ef30946..a2682eb 100644
--- a/FS/FS/msg_template.pm
+++ b/FS/FS/msg_template.pm
@@ -397,8 +397,10 @@ sub prepare {
       $from_addr = scalar( $conf->config($opt{'from_config'}, 
                                          $cust_main->agentnum) );
     }
-    $from_addr ||= scalar( $conf->config('invoice_from',
-                                         $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);
   }
 #  my @cust_msg = ();
 #  if ( $conf->exists('log_sent_mail') and !$opt{'preview'} ) {
diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm
index 3a06914..fe03bd0 100644
--- a/FS/FS/pay_batch.pm
+++ b/FS/FS/pay_batch.pm
@@ -764,7 +764,10 @@ 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'),
+        from    => $conf->config('invoice_from_name') ?
+                   $conf->config('invoice_from_name') . ' <' .
+                   $conf->config('invoice_from') . '>' :
+                   $conf->config('invoice_from'),
         subject => $subject,
         body    => $body,
       );
diff --git a/FS/FS/quotation.pm b/FS/FS/quotation.pm
index b3595ef..e24f1dd 100644
--- a/FS/FS/quotation.pm
+++ b/FS/FS/quotation.pm
@@ -198,8 +198,10 @@ sub email {
 
   # this is where we set the From: address
   $from ||= $conf->config('quotation_from', $self->cust_or_prospect->agentnum )
-         || $conf->config('invoice_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 ));
   $self->SUPER::email( {
     'from' => $from,
     %$opt,
diff --git a/FS/FS/upload_target.pm b/FS/FS/upload_target.pm
index 33088cb..73d2a04 100644
--- a/FS/FS/upload_target.pm
+++ b/FS/FS/upload_target.pm
@@ -163,7 +163,10 @@ 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'),
+      'from'          => $conf->config('invoice_from_name') ?
+                         $conf->config('invoice_from_name') . ' <' .
+                         $conf->config('invoice_from') . '>' :
+                         $conf->config('invoice_from'),
       'to'            => $to,
       'subject'       => $self->subject,
       'nobody'        => 1,
diff --git a/httemplate/misc/email-customers.html b/httemplate/misc/email-customers.html
index 1592630..c74c15b 100644
--- a/httemplate/misc/email-customers.html
+++ b/httemplate/misc/email-customers.html
@@ -103,7 +103,8 @@ Template:
     <& /elements/tr-td-label.html, 'label' => 'From:' &>
       <TD><& /elements/input-text.html,
               'field' => 'from_name',
-              'value' => $conf->config('company_name', $agent_virt_agentnum), #?
+              'value' => $conf->config('invoice_from_name', $agent_virt_agentnum) ||
+                         $conf->config('company_name', $agent_virt_agentnum), #?
               'size'  => 20,
           &> <\
           <& /elements/input-text.html,

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/Conf.pm                        |   32 +++++++++++++++++++++++++++++++-
 FS/FS/Cron/agent_email.pm            |    2 +-
 FS/FS/Cron/upload.pm                 |    2 +-
 FS/FS/Upgrade.pm                     |   31 ++++++++++++++++++++++++++++++-
 FS/FS/cust_bill.pm                   |    2 +-
 FS/FS/cust_credit.pm                 |    2 +-
 FS/FS/cust_main.pm                   |    2 +-
 FS/FS/cust_main/Billing_Realtime.pm  |    2 +-
 FS/FS/cust_pay.pm                    |    2 +-
 FS/FS/cust_pkg.pm                    |    2 +-
 FS/FS/msg_template.pm                |    3 +--
 FS/FS/pay_batch.pm                   |    2 +-
 FS/FS/quotation.pm                   |    3 +--
 FS/FS/upload_target.pm               |    2 +-
 httemplate/misc/email-customers.html |    3 ++-
 15 files changed, 75 insertions(+), 17 deletions(-)




More information about the freeside-commits mailing list