X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FMisc.pm;h=9c18961ea25b1b1fda567825fdfb0556617f5da1;hb=eef99d4b1595d23b73f8800900ba984fe242b8c4;hp=dbebf33b82ad9f51806046c168992ee4e275275d;hpb=cc9bdd96a6a3c70b87ef3ed1a9aa15bb0923d61c;p=freeside.git 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 = '';