Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Mail::Sender character set/encoding

by Rodster001 (Pilgrim)
on Mar 12, 2009 at 19:31 UTC ( #750241=perlquestion: print w/replies, xml ) Need Help??

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


I am using Mail::Sender and when I send an email, characters like (hex 0x92), and (hex 0x94), etc are displaying as a □.

I should mention that the display problem actually happens in Outlook. If I "view source" on the email message, and open it in a text editor, the correct character is there (and has the same hex value). So, I am guessing this is a problem with not with the actual encoding, but a missing header so Outlook will display properly? I also forwarded the message to my Gmail account and in that case the characters are just being omitted. So, I really don't know, but I am stuck.

Anyway, if anyone knows a solution to this it would be much appreciated!

Code below. Note: I have tried both the SendEnc and SendLineEnc methods and encoding types both "quoted-printable" and "7bit". All with the same result.

my $sender = new Mail::Sender { smtp => "localhost", from => "", } or die "Can't create Mail::Sender object: $Mail::Sender::Error\n"; $sender->Open({ to => "", subject => "My Subject", ctype => 'text/html; charset=us-ascii', encoding => "quoted-printable", }) or die "Can't open the message: $sender->{'error_msg'}\n"; $sender->SendEnc($message); $sender->Close();
Thanks for your help!

Replies are listed 'Best First'.
Re: Mail::Sender character set/encoding
by zwon (Abbot) on Mar 12, 2009 at 19:55 UTC

    You specified charset=us-ascii and that means that any characters with codes more than 0x80 are illegal. Try to specify latin1 or whatever your actual charset is.

      Hey Thanks, that was it (latin1). Is there a universal way of determining a character set being used (i.e. in a given email, word document, text file, etc). Or do you have to poke around or just "know". Thanks again!
        Is there a universal way of determining a character set being used

        You can try Encode::Guess, but generally it's better to "just know", as there's no easy failsafe way to determine encodings. In other words, the module can tell apart UTF-8 from ISO-8859-1, but is having a hard time figuring out if something is ISO-8859-1 or ISO-8859-15... (typically, you'd also need to specify potential candidates as hints, e.g. via ->set_suspects())

        There are some modules that can detect text encoding, but generally you should just know.

Re: Mail::Sender character set/encoding
by talexb (Chancellor) on Mar 13, 2009 at 02:52 UTC

    Just wanted to pass along a link to my recent adventures in that area, although it looks like you have a solution that works for you already.

    Alex / talexb / Toronto

    "Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

      For extra credit (ok, it's really just some background information on character encodings), there is also How to handle encodings?

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://750241]
Front-paged by Arunbear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2022-11-29 12:22 GMT
Find Nodes?
    Voting Booth?