X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FMisc.pm;h=ed4b1032196052ddafcd0303ef817c0341e5ddec;hb=57d4a5ffe7b86d032339d6eefe1a22277f3ca113;hp=eedc736ee8cb1df5f86ac3acb32e6885b087df5c;hpb=4137519a5a1a9380c59385536883e3e228627ee8;p=freeside.git diff --git a/FS/FS/Misc.pm b/FS/FS/Misc.pm index eedc736ee..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,13 +261,11 @@ sub send_email { } 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/; + # 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 @@ -281,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, @@ -375,7 +380,7 @@ sub generate_email { 'Type' => 'text/plain', 'Encoding' => 'quoted-printable', #'Encoding' => '7bit', - 'Data' => $data, + 'Data' => Encode::encode_utf8($data), 'Disposition' => 'inline', ); @@ -396,7 +401,7 @@ sub generate_email { ' ', ' ', ' ', - @html_data, + ( map Encode::encode_utf8($_), @html_data ), ' ', '', ],