summaryrefslogtreecommitdiff
path: root/FS/FS/msg_template
diff options
context:
space:
mode:
authorMitch Jackson <mitch@freeside.biz>2018-01-28 02:41:17 -0600
committerMitch Jackson <mitch@freeside.biz>2018-09-25 22:36:05 -0400
commit087d74f7289c302b7b79a97df4ae0f354ef45922 (patch)
tree7e819e931760b74fac501c41ae8dd704dd60be44 /FS/FS/msg_template
parent774a522ebf772f28ccf3b19f531e2424c62fcc0f (diff)
RT# 73421 Fixed E-Mail pipeline to obey contact opt-in flags
Diffstat (limited to 'FS/FS/msg_template')
-rw-r--r--FS/FS/msg_template/email.pm29
1 files changed, 26 insertions, 3 deletions
diff --git a/FS/FS/msg_template/email.pm b/FS/FS/msg_template/email.pm
index 3850ede..19b9367 100644
--- a/FS/FS/msg_template/email.pm
+++ b/FS/FS/msg_template/email.pm
@@ -210,6 +210,22 @@ go away in the future.
A L<MIME::Entity> (or arrayref of them) to attach to the message.
+=item to_contact_classnum
+
+Set a string containing a comma-separated list. This list may contain:
+
+- the text "invoice" indicating emails should only be sent to contact_email
+ addresses with the invoice_dest flag set
+- the text "message" indicating emails should only be sent to contact_email
+ addresses with the message_dest flag set
+ - numbers representing classnum id values for email contact classes.
+ If any classnum are present, emails should only be sent to contact_email
+ addresses where contact_email.classnum contains one of these classes.
+ The classnum 0 also includes where contact_email.classnum IS NULL
+
+If neither 'invoice' nor 'message' has been specified, this method will
+behave as if 'invoice' had been selected
+
=cut
=back
@@ -296,8 +312,16 @@ sub prepare {
my $classnum = $opt{'to_contact_classnum'} || '';
my @classes = ref($classnum) ? @$classnum : split(',', $classnum);
- # traditional behavior: send to all invoice recipients
- @classes = ('invoice') unless @classes;
+
+ # There are two e-mail opt-in flags per contact_email address.
+ # If neither 'invoice' nor 'message' has been specified, default
+ # to 'invoice'.
+ #
+ # This default supports the legacy behavior of
+ # send to all invoice recipients
+ push @classes,'invoice'
+ unless grep {$_ eq 'invoice' || $_ eq 'message'} @classes;
+
@to = $cust_main->contact_list_email(@classes);
# not guaranteed to produce contacts, but then customers aren't
# guaranteed to have email addresses on file. in that case, env_to
@@ -630,4 +654,3 @@ L<FS::Record>, schema.html from the base documentation.
=cut
1;
-