Perl, Mail, and Special Characters

Discussion in 'Programming' started by SecureCP, Aug 1, 2010.

  1. #1
    Hey all,
    I'm facing an issue, I do not normally author in perl so this is somewhat foreign to me. I need this script to shoot out email in plain/text, russian characters, and need for the content to be automatically shown in user's mail clients without having to switch views to utf-8 encoding. Here's what I have:
    
    	## DATA TO SEND
            $smtp->data;
            $smtp->datasend("From: $cCompaniesName <$cCompaniesReply>\n");
            $smtp->datasend("To: $to\n");
            $smtp->datasend("Subject: $subject\n");
            $smtp->datasend("Header: Content-Type: text/plain; charset=windows-1251\nHeader: Content-Transfer-Encoding: 8bit\n");
            $smtp->datasend("$message");
            $smtp->dataend
    
    Code (markup):
    And the following:

    
    local ($to,$subject,$message,$from,$ccto) = @_;
            if (!$from){ $from = "$adminemail"; }
            open (MAIL, "| $sendmail -t -O DefaultCharSet=UTF-8");
            print MAIL "To: $to\n";
            print MAIL "From: $fromname <$from>\n";
            if ($ccto){
                    print MAIL "BCC: $ccto\n";
            }
    	print MAIL "Subject: $subject\n\n";
            print MAIL "Content-type: text/plain charset=koi8-r\r\n";
            print MAIL "$message";
            close (MAIL);
    }
    Code (markup):
    Can anyone point me in the proper direction, I know right now there are multiple charsets in this. I will make them all the same once I can square this away.

    Thanks!
     
    SecureCP, Aug 1, 2010 IP