X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FMisc.pm;h=ed4b1032196052ddafcd0303ef817c0341e5ddec;hb=57d4a5ffe7b86d032339d6eefe1a22277f3ca113;hp=e425c4a4b5e0c1cbfd146389158b1b933783c484;hpb=e78d51a5053c8d3c0c7192c8b5cdeff5999fafd7;p=freeside.git diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm index e425c4a4b..ed4b10321 100644 --- a/FS/FS/Misc.pm +++ b/FS/FS/Misc.pm @@ -156,7 +156,11 @@ sub send_email { unshift @mimeparts, { 'Type' => ( $options{'content-type'} || 'text/plain' ), - 'Data' => $options{'body'}, + 'Charset' => 'UTF-8', + 'Data' => ( $options{'content-type'} =~ /^text\// + ? Encode::encode_utf8( $options{'body'} ) + : $options{'body'} + ), 'Encoding' => ( $options{'content-type'} ? '-SUGGEST' : '7bit' ), 'Disposition' => 'inline', }; @@ -165,7 +169,10 @@ sub send_email { @mimeargs = ( 'Type' => ( $options{'content-type'} || 'text/plain' ), - 'Data' => $options{'body'}, + 'Data' => ( $options{'content-type'} =~ /^text\// + ? Encode::encode_utf8( $options{'body'} ) + : $options{'body'} + ), 'Encoding' => ( $options{'content-type'} ? '-SUGGEST' : '7bit' ), ); @@ -254,8 +261,13 @@ sub send_email { } push @to, $options{bcc} if defined($options{bcc}); - # make sure - my @env_to = split(/\s*,\s*/, join(', ', @to)); + # 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, @@ -274,7 +286,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, @@ -368,7 +380,7 @@ sub generate_email { 'Type' => 'text/plain', 'Encoding' => 'quoted-printable', #'Encoding' => '7bit', - 'Data' => $data, + 'Data' => Encode::encode_utf8($data), 'Disposition' => 'inline', ); @@ -389,7 +401,7 @@ sub generate_email { ' ', ' ', ' ', - @html_data, + ( map Encode::encode_utf8($_), @html_data ), ' ', '', ],