From: "Gunnar Hjalmarsson" <nore...@gunnar.cc>
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.

If I used it in a UTF-8 encoded perl program and was also using "use utf8;" in it, I expected that it understand that it should be encoded to UTF-8.

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.

Well, instead of the old type encoding of ISO-8859-1, it would have been much better if it would encode to UTF-8 and also do the MIME encoding.

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";

Well, I think it is too low level to need to explicitly do the MIME encoding...

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.

Yes I know this, but since any char from any language can be found in the UTF-8 encoding, I don't think this is such a big issue... unless you need to modify an old code.

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;

Oh sorry, I was using Mail::Sender::Easy because it has a much nicer syntax than Mail::Sender, and Mail::Sender::Easy also adds some headers that can't be disabled with a configuration.

Octavian


--
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