X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FMisc.pm;h=a2d1b3ed5b82cb747ce642277b98b10793e3dfe3;hb=f4daf7e8c831fe126dc3fd1d6d0db5ee3b46d602;hp=18cb275bf1bb2a3999baaa866811ca6a87e20352;hpb=2b2dd969f3c18751afc583ad1e836ab8e6f73b5d;p=freeside.git diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm index 18cb275bf..a2d1b3ed5 100644 --- a/FS/FS/Misc.pm +++ b/FS/FS/Misc.pm @@ -256,10 +256,17 @@ sub send_email { } push @to, $options{bcc} if defined($options{bcc}); + # fully unpack all addresses found in @to (including Bcc) to make the + # envelope list + my @env_to; + foreach my $dest (@to) { + push @env_to, map { $_->address } Email::Address->parse($dest); + } + 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')) { @@ -274,7 +281,7 @@ sub send_email { if ( $conf->exists('log_sent_mail') ) { my $cust_msg = FS::cust_msg->new({ 'env_from' => $options{'from'}, - 'env_to' => join(', ', @to), + 'env_to' => join(', ', @env_to), 'header' => $message->header_as_string, 'body' => $message->body_as_string, '_date' => $time, @@ -510,6 +517,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; $_; } @@ -532,6 +542,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.