summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormark <mark>2010-08-16 17:50:59 +0000
committermark <mark>2010-08-16 17:50:59 +0000
commitcf7692279ed80fc79611df83863ebf3b6bef7c96 (patch)
tree495b3cf91bbb01e434d96a6581203397521e64b4
parentb98badc88cb1e1fcd3d292b494daa7ba4114bdb6 (diff)
Bcc address for impending recur notices, RT#8953
-rw-r--r--FS/FS/Cron/notify.pm1
-rw-r--r--FS/FS/Misc.pm16
-rw-r--r--FS/FS/Schema.pm1
-rw-r--r--FS/FS/cust_main.pm3
-rw-r--r--FS/FS/msg_template.pm20
-rw-r--r--httemplate/edit/msg_template.html2
6 files changed, 30 insertions, 13 deletions
diff --git a/FS/FS/Cron/notify.pm b/FS/FS/Cron/notify.pm
index 74840a6e7..7664ff2ff 100644
--- a/FS/FS/Cron/notify.pm
+++ b/FS/FS/Cron/notify.pm
@@ -115,6 +115,7 @@ END
'package' => $packages[0],
'recurdate' => $recurdates[0],
},
+ 'bcc' => $conf->config('impending_recur_bcc'),
);
} #if $msgnum
warn "Error notifying, custnum ". $cust_main->custnum. ": $error" if $error;
diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm
index 6799a24b8..94536ebea 100644
--- a/FS/FS/Misc.pm
+++ b/FS/FS/Misc.pm
@@ -58,6 +58,10 @@ Sender address, required
Recipient address, required
+=item bcc
+
+Blind copy address, optional
+
=item subject
email subject, required
@@ -91,6 +95,7 @@ sub generate_email {
my %return = (
'from' => $args{'from'},
'to' => $args{'to'},
+ 'bcc' => $args{'bcc'},
'subject' => $args{'subject'},
);
@@ -237,7 +242,7 @@ sub send_email {
# join("\n", map { " $_: ". $options{$_} } keys %options ). "\n"
}
- my $to = ref($options{to}) ? join(', ', @{ $options{to} } ) : $options{to};
+ my @to = ref($options{to}) ? @{ $options{to} } : ( $options{to} );
my @mimeargs = ();
my @mimeparts = ();
@@ -296,7 +301,7 @@ sub send_email {
my $message = MIME::Entity->build(
'From' => $options{'from'},
- 'To' => $to,
+ 'To' => join(', ', @to),
'Sender' => $options{'from'},
'Reply-To' => $options{'from'},
'Date' => time2str("%a, %d %b %Y %X %z", time),
@@ -355,9 +360,12 @@ sub send_email {
$smtp_opt{'ssl'} = 1 if defined($enc) && $enc eq 'tls';
$transport = Email::Sender::Transport::SMTP->new( %smtp_opt );
}
-
+
+ push @to, $options{bcc} if defined($options{bcc});
local $@; # just in case
- eval { sendmail($message, { transport => $transport }) };
+ eval { sendmail($message, { transport => $transport,
+ from => $options{from},
+ to => \@to }) };
if(ref($@) and $@->isa('Email::Sender::Failure')) {
return ($@->code ? $@->code.' ' : '').$@->message
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index e858d31a8..8772a3dbf 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -2714,6 +2714,7 @@ sub tables_hashref {
'body', 'blob', 'NULL', '', '', '',
'disabled', 'char', 'NULL', 1, '', '',
'from_addr', 'varchar', 'NULL', 255, '', '',
+ 'bcc_addr', 'varchar', 'NULL', 255, '', '',
],
'primary_key' => 'msgnum',
'unique' => [ ['msgname', 'mime_type'] ],
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 93d4a6908..b9843d44a 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -9423,6 +9423,8 @@ I<from> - the email sender (default is invoice_from)
I<to> - comma-separated scalar or arrayref of recipients
(default is invoicing_list)
+I<bcc> - blind-copy recipient address (default is none)
+
I<subject> - The subject line of the sent email notification
(default is "Notice from company_name")
@@ -9499,6 +9501,7 @@ sub notify {
send_email(from => $from,
to => $to,
+ bcc => $options{bcc},
subject => $subject,
body => $notify_template->fill_in( PACKAGE =>
'FS::notify_template::_template' ),
diff --git a/FS/FS/msg_template.pm b/FS/FS/msg_template.pm
index 488d8833b..2e5ef0a63 100644
--- a/FS/FS/msg_template.pm
+++ b/FS/FS/msg_template.pm
@@ -255,9 +255,10 @@ sub prepare {
my $conf = new FS::Conf;
(
- 'from' => $self->from ||
+ 'from' => $self->from_addr ||
scalar( $conf->config('invoice_from', $cust_main->agentnum) ),
'to' => \@to,
+ 'bcc' => $self->bcc_addr || undef,
'subject' => $subject,
'html_body' => $body,
'text_body' => HTML::FormatText->new(leftmargin => 0, rightmargin => 70
@@ -396,26 +397,27 @@ sub _upgrade_data {
my ($self, %opts) = @_;
my @fixes = (
- [ 'alerter_msgnum', 'alerter_template', '', '' ],
- [ 'cancel_msgnum', 'cancelmessage', 'cancelsubject', '' ],
- [ 'decline_msgnum', 'declinetemplate', '', '' ],
- [ 'impending_recur_msgnum', 'impending_recur_template', '', '' ],
- [ 'payment_receipt_msgnum', 'payment_receipt_email', '', '' ],
- [ 'welcome_msgnum', 'welcome_email', 'welcome_email-subject', 'welcome_email-from' ],
- [ 'warning_msgnum', 'warning_email', 'warning_email-subject', 'warning_email-from' ],
+ [ 'alerter_msgnum', 'alerter_template', '', '', '' ],
+ [ 'cancel_msgnum', 'cancelmessage', 'cancelsubject', '', '' ],
+ [ 'decline_msgnum', 'declinetemplate', '', '', '' ],
+ [ 'impending_recur_msgnum', 'impending_recur_template', '', '', 'impending_recur_bcc' ],
+ [ 'payment_receipt_msgnum', 'payment_receipt_email', '', '', '' ],
+ [ 'welcome_msgnum', 'welcome_email', 'welcome_email-subject', 'welcome_email-from', '' ],
+ [ 'warning_msgnum', 'warning_email', 'warning_email-subject', 'warning_email-from', '' ],
);
my $conf = new FS::Conf;
my @agentnums = ('', map {$_->agentnum} qsearch('agent', {}));
foreach my $agentnum (@agentnums) {
foreach (@fixes) {
- my ($newname, $oldname, $subject, $from) = @$_;
+ my ($newname, $oldname, $subject, $from, $bcc) = @$_;
if ($conf->exists($oldname, $agentnum)) {
my $new = new FS::msg_template({
'msgname' => $oldname,
'agentnum' => $agentnum,
'from_addr' => ($from && $conf->config($from, $agentnum)) ||
$conf->config('invoice_from', $agentnum),
+ 'bcc_addr' => ($bcc && $conf->config($from, $agentnum)) || '',
'subject' => ($subject && $conf->config($subject, $agentnum)) || '',
'mime_type' => 'text/html',
'body' => join('<BR>',$conf->config($oldname, $agentnum)),
diff --git a/httemplate/edit/msg_template.html b/httemplate/edit/msg_template.html
index c38c40e4a..460f4dcc2 100644
--- a/httemplate/edit/msg_template.html
+++ b/httemplate/edit/msg_template.html
@@ -10,11 +10,13 @@
'fields' => [ 'msgname',
'subject',
'from_addr',
+ 'bcc_addr',
{ field=>'body', type=>'htmlarea', width=>763 },
],
'labels' => { 'msgnum' => 'Template',
'msgname' => 'Template name',
'from_addr' => 'Return address',
+ 'bcc_addr' => 'Bcc address (optional)',
'subject' => 'Message subject',
'body' => 'Message template',
},