php - Russian encoding not consistent on mail.ru with phpmailer -


im sending automated emails russian users, used utf-8 encoding , when open in gmail shows perfect, in outlook shows incorrect in mail.ru popular email account russian users shows gobblygook.

so sent email outlook in accryllic mail.ru , showed same content without problem, changed encoding windows-1251, again shows fine in gmail in mail.ru (who dont have option find switch encoding , dont support utf-8) shows different type of gooblygook.

code here:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="content-type" content="text/html; charset=koi8-r" /> <title>untitled document</title>   </head>  //error_reporting(e_all); error_reporting(e_strict);  date_default_timezone_set('america/toronto');  require_once('phpmailer_5.2.2/class.phpmailer.php'); //include("class.smtp.php"); // optional, gets called within class.phpmailer.php if not loaded  $mail             = new phpmailer();   $body = "Это письмо отправлено потому. english";     $mail->issmtp(); // telling class use smtp $mail->host       = "smtp.gmail.com"; // smtp server $mail->smtpdebug  = 1;                     // enables smtp debug information (for testing)                                            // 1 = errors , messages                                            // 2 = messages $mail->smtpauth   = true;                  // enable smtp authentication $mail->smtpsecure = "ssl";                 // sets prefix servier $mail->host       = "smtp.gmail.com";      // sets gmail smtp server $mail->port       = 465;                   // set smtp port gmail server $mail->username   = "xxx@gmail.com";  // gmail username $mail->password   = "xxx";            // gmail password  $mail->setfrom('xxx@gmail.com', 'xxx');  $mail->addreplyto("xxx@gmail.com","xxx");  $mail->subject    = "urgent";  $mail->altbody    = "to view message, please use html compatible email viewer!"; // optional, comment out , test  $mail->msghtml($body);  $address1 = "xxx@mail.ru"; $address2 = "xxx@gmail.com";   if(!$mail->send()) {   echo "mailer error: " . $mail->errorinfo; } else {   echo "message sent!"; } 

surely there way send russian message mail.ru, im doing stupid cause sending outlook acryllic works maybe have put encoding somewhere else other header.

my plan auto encode message since dont support utf-8 new plan display message saying "click here view message in webpage" in russian , can control encoding myself , display fine cant figure out how send russian message mail.ru because displays in gobblygook win-1251,utf-8 , kio

the charset set in html header have absolutely no effect on php code running later in same script. php couldn't care less client-side charsets, until client sends data php. need generate proper mime email, , set proper charsets in headers that.

i'd suggest using phpmailer or swiftmailer, both make sending mime emails trivial, , far far easier , more reliable utter garbage php's mail() function.


Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -