summaryrefslogtreecommitdiff
path: root/FS
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2013-05-20 12:27:25 -0700
committerMark Wells <mark@freeside.biz>2013-05-20 12:27:25 -0700
commit9bc26d39cb527466f3bd5594c14bdcd548bc99cd (patch)
treeb20dda0d36011efddbe96b3695cdb318bc537977 /FS
parentcfcc6dd44b65698bea942ca0cf2e010141267303 (diff)
allow friendly from: addresses on email notices, #22962
Diffstat (limited to 'FS')
-rw-r--r--FS/FS/Misc.pm11
-rw-r--r--FS/FS/UI/Web.pm4
-rw-r--r--FS/FS/cust_main_Mixin.pm1
3 files changed, 14 insertions, 2 deletions
diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm
index dbebf33b8..9c18961ea 100644
--- a/FS/FS/Misc.pm
+++ b/FS/FS/Misc.pm
@@ -171,8 +171,15 @@ sub send_email {
}
+ my $from = $options{from};
+ $from =~ s/^\s*//; $from =~ s/\s*$//;
+ if ( $from =~ /^(.*)\s*<(.*@.*)>$/ ) {
+ # a common idiom
+ $from = $2;
+ }
+
my $domain;
- if ( $options{'from'} =~ /\@([\w\.\-]+)/ ) {
+ if ( $from =~ /\@([\w\.\-]+)/ ) {
$domain = $1;
} else {
warn 'no domain found in invoice from address '. $options{'from'}.
@@ -247,7 +254,7 @@ sub send_email {
push @to, $options{bcc} if defined($options{bcc});
local $@; # just in case
eval { sendmail($message, { transport => $transport,
- from => $options{from},
+ from => $from,
to => \@to }) };
my $error = '';
diff --git a/FS/FS/UI/Web.pm b/FS/FS/UI/Web.pm
index c8ad430b2..bcea7763f 100644
--- a/FS/FS/UI/Web.pm
+++ b/FS/FS/UI/Web.pm
@@ -678,6 +678,10 @@ sub start_job {
#warn 'froze string of size '. length(nfreeze(\%param)). " for job args\n"
# if $DEBUG;
+ #
+ # XXX FS::queue::insert knows how to do this.
+ # not changing it here because that requires changing it everywhere else,
+ # too, but we should eventually fix it
my $error = $job->insert( '_JOB', encode_base64(nfreeze(\%param)) );
diff --git a/FS/FS/cust_main_Mixin.pm b/FS/FS/cust_main_Mixin.pm
index a0677060e..212c04e0f 100644
--- a/FS/FS/cust_main_Mixin.pm
+++ b/FS/FS/cust_main_Mixin.pm
@@ -539,6 +539,7 @@ sub process_email_search_result {
die "error loading FS::$table: $@\n" if $@;
my $error = "FS::$table"->email_search_result( $param );
+ dbh->commit; # save failed jobs before rethrowing the error
die $error if $error;
}