Octavian Râsnita wrote:
From: "Gunnar Hjalmarsson" <nore...@gunnar.cc>
Well, if I understand it correctly, Mail::Builder::Simple *enforces* the use of UTF-8, which is something I don't like.

Well, I like that, because it is more simple to send special chars from more languages, but without needing to know nor to specify the charset explicitly when creating the message.

Ok, then we are simply not agreed on this one.

This code works, and the message is displayed just fine in my email client:

    use Mail::Sender;
    ref (new Mail::Sender -> MailMsg( {
        smtp      => 'localhost',
        charset   => 'ISO-8859-1',
        from      => '"Pär" <m...@example.com>',
        to        => 'me <m...@example.com>',
        subject   => 'Östra Vägen',
        msg       => "Hello,\n\nWondering about Östra Vägen.\n",
    } )) or die "Cannot send mail: $Mail::Sender::Error\n";

I have tried to use the same code but I've changed the charset to UTF-8 (also tried utf8) and the subject to:

subject   => 'Östra Vägen astâîASTÂÎ',

If you change the charset to UTF-8, you'd better also pass UTF-8 encoded strings to the module. That's not a UTF-8 string.

<snip>

So there should be some bugs in Mail::Sender or the module it uses for encoding the headers.

As far as I know, Mail::Sender does not encode the headers, but I wouldn't call that a bug. It just means that unless the subject line is ISO-8859-1 (or ASCII), you need to encode it using quoted-printable or base64.

In my experience, Mail::Sender sends messages with any encoding. This code works for me:

    use Mail::Sender;
    ref (new Mail::Sender -> MailMsg( {
        smtp      => 'localhost',
        charset   => 'UTF-8',
        from      => '"Pär" <m...@example.com>',
        to        => 'me <m...@example.com>',
        subject   => '=?UTF-8?Q?' .
          MIME::QuotedPrint::encode('Östra Vägen', '') . '?=',
        msg       => "Hello,\n\nWondering about Östra Vägen.\n",
    } )) or die "Cannot send mail: $Mail::Sender::Error\n";

When trying to send the same message using Mail::Builder::Simple, I encountered two problems:

<snip>

2) Mail::Builder objected, claiming that my stated "From:" address

       "Pär" <m...@example.com>

is not valid (which is something I don't understand).

It tells you this because the syntax for using it with Mail::Builder::Simple is different. You need to use:

from => ['m...@example.com', 'Pär'],

Ok, thanks. The automatic encoding of headers with non-ASCII characters is nice, but Mail::Builder::Simple is still not very useful to me, since it only permits UTF-8 encoded strings.

I also don't like that Mail::Sender ads strange headers to the mail messages and I don't know why it does this.

It doesn't if you say

    $Mail::Sender::NO_X_MAILER = 1;

<snip>

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to