Email subject MIME encoding in Perl.

前端 未结 2 1215
醉梦人生
醉梦人生 2021-01-24 02:06

I am trying to send an email with non-ASCII characters in the subject line under Perl 5.8.5. My simple example uses the word \"Änderungen\" (German umlaut), but instead of corre

相关标签:
2条回答
  • 2021-01-24 02:12

    In your question, you declared:

    my $subject_encoded = encode("MIME-Q", $subject);
    

    But you didn't use it later.

    print MAIL "Subject: $subject\n\n";
    

    should be:

    print MAIL "Subject: $subject_encoded\n\n";
    
    0 讨论(0)
  • 2021-01-24 02:20

    Your editor treats the file as UTF-8, so it shows

    my $subject = "Änderungen";
    

    Perl effectively treats the file as iso-8859-1, so it sees

    my $subject = "Ã?nderungen";
    

    Tell Perl you encoded your script using UTF-8 by adding

    use utf8;
    
    0 讨论(0)
提交回复
热议问题