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

Dear monks, Once again, I need your advices on a perl issue. Here is the thing: I wrote a little script to automatically send email after a html form have been submitted. However, since this service is directed towards french speaking people, I need to display accented characters in the outgoing emails. Unfortunately, the accented characters (éŕč, etc...) are not displayed correctly. Here is my script:
use Net::SMTP; $smtp = Net::SMTP->new( 'smtp.server.com', Debug => 1, bits=>"8"); # connect to an SMTP server $smtp->auth('login', 'password' ); $smtp->mail( 'login@server.com' ); # use the sender's address here #print $smtp->banner(); $smtp->to('someone@something.com'); # recipient's address $smtp->data(); # Start the mail # Send the header. $smtp->datasend("To: someone_2@something.com\n"); $smtp->datasend("From: 'someone@something.com\n"); $smtp->datasend("Subject: Inscription Résumé"); $smtp->datasend("\n"); # Send the body. $smtp->datasend("Résumé"); $smtp->dataend(); # Finish sending the mail $smtp->quit; # Close the SMTP connection
The output of résumé will be displayed as: R├⌐sum├⌐. Any ideas?

Replies are listed 'Best First'.
Re: net::smtp accented characters
by ikegami (Patriarch) on Aug 14, 2009 at 19:46 UTC

    For starters, I think you saved the source code as UTF-8, but you told Perl it's encoded using iso-latin-1 (by omitting use utf8;).

    But fixing that is probably not enough since I think datasend expects the data must be properly formatted for a MIME message and it isn't. You may prefer to use a module that operates at a higher level.

      Thanks for the replies guys! I followed Derby 's link and it worked like a charm! Cheers!
Re: net::smtp accented characters
by derby (Abbot) on Aug 14, 2009 at 19:22 UTC