diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index eb21123b98..f0c019f362 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,7 @@ +2011-07-29 Koichiro Kikuchi + + * lib/PandoraFMS/Tools.pm: Send utf8 email properly. + 2011-07-27 Ramon Novoa * lib/PandoraFMS/Config.pm: Read configuration for the new enterprise diff --git a/pandora_server/lib/PandoraFMS/Tools.pm b/pandora_server/lib/PandoraFMS/Tools.pm index 2d9d8be444..ff66bcad99 100644 --- a/pandora_server/lib/PandoraFMS/Tools.pm +++ b/pandora_server/lib/PandoraFMS/Tools.pm @@ -23,6 +23,7 @@ use POSIX qw(setsid strftime); use POSIX; use PandoraFMS::Sendmail; use HTML::Entities; +use Encode; # New in 3.2. Used to sendmail internally, without external scripts # use Module::Loaded; @@ -333,13 +334,20 @@ sub pandora_sendmail { my %mail = ( To => $to_address, Message => $message, - Subject => $subject, + Subject => encode('MIME-Header', $subject), 'X-Mailer' => "Pandora FMS", Smtp => $pa_config->{"mta_address"}, Port => $pa_config->{"mta_port"}, From => $pa_config->{"mta_from"}, ); + # Check if message has non-ascii chars. + # non-ascii chars should be encoded in UTF-8. + if ($message =~ /[^[:ascii:]]/o) { + $mail{Message} = encode("UTF-8", $mail{Message}); + $mail{'Content-Type'} = 'text/plain; charset="UTF-8"'; + } + if ($pa_config->{"mta_user"} ne ""){ $mail{auth} = {user=>$pa_config->{"mta_user"}, password=>$pa_config->{"mta_pass"}, method=>$pa_config->{"mta_auth"}, required=>1 }; }