in reply to Problem with russian / cyrillic in e-mail program.

If you have characters outside the 7-bit ASCII range in headers, you need to base-64 encode the headers, and prefix =?...?B:

use MIME::Base64; my $charset = 'your charset'; my $subject = 'your subject, containing non-ASCII chars'; my $header = "=?$charset?B?".encode_base64($subject)."?=";

Replies are listed 'Best First'.
Re^2: Problem with russian / cyrillic in e-mail program.
by afoken (Chancellor) on Apr 03, 2010 at 18:58 UTC

    ... or just let Encode::MIME::Header do the work for you.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re^2: Problem with russian / cyrillic in e-mail program.
by dbmathis (Scribe) on Apr 03, 2010 at 18:00 UTC

    I am not sure how to implement this into my code. Also do I need to check for non-ascii?

      You can use it as well for ASCII.

      I'm not sure what you mean by "not sure how to implement this into my code" - instead of passing in the subject literally, you construct the encoded subject string and pass that one in. Where are you having problems exactly?

        Sorry for being vague. This is what I tried, thought it would work this way but it didn't. Wasn't sure what charset to use either.

        sub send_info { # Adjust sender, recipient and your SMTP mailhost use MIME::Base64; my $charset = 'x-mac-cyrillic'; my $from_address = $from; my $to_address = $infoemail; # Adjust subject and body message my $message_body = "<h2>The following visitor requested informatio +n.</h2><b>Name:</b> $string<br><b>E-mail:</b> $email<br>"; my $subject = "$string is requesting information."; my $subject = "=?$charset?B?".encode_base64($subject)."?="; # Create the multipart container my $msg = MIME::Lite->new ( From => $from_address, To => $to_address, BCC => $bcc, Subject => $subject, Type =>'multipart/mixed' ) or die "Error creating multipart cont +ainer: $!\n"; # Add the text message part $msg->attach ( Type => 'text/html', Data => qq{ $message_body } ) or die "Error adding the text message part: $!\n"; # Now send $msg->send("sendmail") or die "Error e-mailing: $!\n";