MonkeyMonk has asked for the wisdom of the Perl Monks concerning the following question:

Dear monks, I thought I got a grip on UTF8, reading files and sending emails and merrily started to work on Polish translations only to be greeted with strange characters in Outlook mail client. I come back here humbled.
So to state the problem:

1. To enable several people from several countries to type in several languages, it was decided to store the data like so in a separate text file.
German:

$subjectLine= Ihre Rechnung f0XC30XBCr transaktion ###transactionID### $line= Mit freundlichen Gr0XC30XBCssen
( The u with umlaut is stored as corresponding UTF8 codepoint.)

2. I then read the line like so:

$encValue=decode('UTF-8', $line); $encValueSubject=decode('UTF-8', $subjectLine);

3. I create a PDF using PDF:API2 with UTF-8 encoding and the file is stored in $pdfout.

4. I then used the following code to send email:

use Mail::Sender; my $mfrom = $mailFrom ; my $pdfmail = new Mail::Sender {from => $mfrom,smtp => 'localh +ost'}; $pdfmail->MailFile({to => $cemail, subject => $subjectLine, msg => $line."\n", file => $pdfout});

All this works fine for German, Swedish, Norwegian and Danish. Outlook displays everything in the mail correctly.

However, for Polish and Czech , the characters are garbled in the subject line and in the body of the mail. The newlines are also missing in some mails.

Sample text for Czech:

$subjectLine=P0XC50X990XC30XADstup k internetu Wi-Fi $line = S p0XC50X990XC30XA1telskymi pozdravy,

I am using Mail::Sender , gone through every type of setting ( like b_charset, b_encoding etc and nothing seems to work)
Am I missing something fundamental here?

Replies are listed 'Best First'.
Re: UTF-8 Email - German, Swedish Ok...Polish,Czech fails
by ikegami (Patriarch) on Aug 17, 2010 at 00:50 UTC
    I've debugged a similar problem with MIME::Lite. You could take advantage of my work by switching to MIME::Lite or for figuring out how to use Mail::Sender.
Re: UTF-8 Email - German, Swedish Ok...Polish,Czech fails
by choroba (Cardinal) on Aug 16, 2010 at 22:32 UTC
    I am not answering your question, sorry. But there is an error in the second Czech sentence, it should be
    S p0XC50X990XC30XA1telsk0XC30XBDmi pozdravy,
      Thanks for the correction. Will have it updated!
Re: UTF-8 Email - German, Swedish Ok...Polish,Czech fails
by aquarium (Curate) on Aug 16, 2010 at 22:48 UTC
    Have you looked at the encoding and charset parameters to Mail::Sender?
    the hardest line to type correctly is: stty erase ^H