diff options
author | Mark Wells <mark@freeside.biz> | 2013-05-20 12:36:06 -0700 |
---|---|---|
committer | Mark Wells <mark@freeside.biz> | 2013-05-20 12:36:06 -0700 |
commit | eef99d4b1595d23b73f8800900ba984fe242b8c4 (patch) | |
tree | a4f38fa6f8b24b8e53f45a96c6a9e14ca3e446ff /FS/FS/Misc.pm | |
parent | 508756cf10352b6cf54a32fbce18ec57121214ce (diff) |
allow friendly from: addresses on email notices, #22962
Diffstat (limited to 'FS/FS/Misc.pm')
-rw-r--r-- | FS/FS/Misc.pm | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm index dbebf33..9c18961 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 = ''; |