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.
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ÂÎ',
But instead of this subject, in the message appears:
Östra Vägen astâîAST=Î
(It appear a "=" sign instead of Â, even though when used in another
context, Â appears well.)
And when I see the message subject in the list of messages (in Outlook
Express), the subject appears as:
Ã-stra Vägen ÄfÅYţâîÄ,ÅzÅ¢Ã=,ÃZ
So there should be some bugs in Mail::Sender or the module it uses for
encoding the headers.
Of course, that bad encoded header appeared when I didn't used "use utf8;"
in my program even though I should use it, because if I add "use utf8;",
then the program doesn't work at all, and gives the following error:
Wide character in subroutine entry at E:/perl510/site/lib/Mail/Sender.pm
line 148, <GEN0> line 12.
So I can't send well UTF-8 encoded messages using Mail::Sender.
I already use Mail::Sender::Easy, but I've abandoned using it for the
reasons above.
When trying to send the same message using Mail::Builder::Simple, I
encountered two problems:
1) I couldn't find a way to change the charset.
Why would you want to change the charset? The same text could be sent as
UTF-8, and the message could also contain chars from other languages which
are not defined in ISO-8859-1, and you won't need to specify any charset
explicitly.
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'],
This way you don't need to interpolate the scalar vars in a string if you
need to get them from a database for example because you can do:
from => [$email, $name],
I also don't like that Mail::Sender ads strange headers to the mail messages
and I don't know why it does this.
If someone really wants to use it for sending spam, he can change
Mail::Sender very easy and can send spam without any problem...
Octavian
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/