X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FMisc.pm;h=eedc736ee8cb1df5f86ac3acb32e6885b087df5c;hb=a238acfb85cd4bef6a99bfe3560a0999c9386dfb;hp=8049fdecee572cc9465dcab237536ba1963efc49;hpb=b18e96a9a39a8ec2cb3298bb1cfcab13622d23ab;p=freeside.git diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm index 8049fdece..eedc736ee 100644 --- a/FS/FS/Misc.pm +++ b/FS/FS/Misc.pm @@ -252,12 +252,21 @@ 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}); + # make sure + my @env_to = split(/\s*,\s*/, join(', ', @to)); + # strip display-name from envelope addresses + foreach (@env_to) { + s/^\s*//; + s/\s*$//; + s/^(.*)\s*<(.*@.*)>$/$2/; + } + local $@; # just in case eval { sendmail($message, { transport => $transport, from => $from, - to => \@to }) }; + to => \@env_to }) }; my $error = ''; if(ref($@) and $@->isa('Email::Sender::Failure')) { @@ -534,6 +543,9 @@ use Locale::SubCountry; sub states_hash { my($country) = @_; + #a hash? not expecting an explosion of business from unrecognized countries.. + return states_hash_nosubcountry($country) if $country eq 'XC'; + my @states = # sort map { s/[\n\r]//g; $_; } @@ -556,6 +568,27 @@ sub states_hash { @states; } +sub states_hash_nosubcountry { + my($country) = @_; + + my @states = +# sort + map { s/[\n\r]//g; $_; } + map { $_->state; } + qsearch({ + 'select' => 'state', + 'table' => 'cust_main_county', + 'hashref' => { 'country' => $country }, + 'extra_sql' => 'GROUP BY state', + }); + + #"i see your schwartz is as big as mine!" + map { ( $_->[0] => $_->[1] ) } + sort { $a->[1] cmp $b->[1] } + map { [ $_ => $_ ] } + @states; +} + =item counties STATE COUNTRY Returns a list of counties for this state and country.