PhpMailer Chinese garbled problem I used phpmailer class library to send an email, encoding has been set to UTF-8, but if the sender, recipient, and subject contains Chinese characters, it will show garbled problem, very uncomfortable. I found some methods from the internet. they are modifying the class. phpmailer. php file. Because I don't want to modify it, I want to ask someone else for advice .. Thank you ., C/C ++ phpMailer Chinese garbled problem
I want to send an email using the phpmailer class library. the encoding has been set to utf-8. However, if the sender, recipient, and topic contain Chinese characters, it will be garbled and uncomfortable. I found some methods from the internet. they are modifying the class. phpmailer. php file. Because I don't want to modify it, I want to ask someone else for advice .. Thank you.
------ Solution --------------------
C/C ++ code
I tried it and succeeded. I just picked it and entered it on the code website. The title and content are not garbled. Is the main php file windows or linux? Note that the encoding of the PHP file is the same as that set by mailer. The latest phpmailer and 163 are sent to QQ.
CharSet = "UTF-8"; // Set the mail encoding, the default ISO-8859-1, this must be set if you send Chinese, otherwise garbled $ mail-> IsSMTP (); // Set the SMTP Service $ mail-> SMTPDebug = 1; // enable SMTP debugging // 1 = errors and messages // 2 = messages only $ mail-> SMTPAuth = true; // enable the SMTP verification function $ mail-> Host = "smtp.163.com"; // SMTP server $ mail-> Port = 25; // SMTP server port $ mail-> Username = "abcdii"; // SMTP server Username $ mail-> Password = "xxxx "; // SMTP server password $ mail-> SetFrom ('abcdii @ 163.com ', 'L Iangdong '); $ mail-> AddReplyTo ("abcdii@163.com", "liangdong"); $ mail-> Subject = $ subject; $ mail-> AltBody = "To view the message, please use an HTML compatible email viewer! -From www.jiucool.com "; // optional, comment out and test $ mail-> MsgHTML ($ body); $ address = $ to; $ mail-> AddAddress ($ address, "liangdong"); // $ mail-> AddAttachment ("images/phpmailer.gif"); // attachment // $ mail-> AddAttachment ("images/phpmailer_mini.gif "); // attachment if (! $ Mail-> Send () {echo "Mailer Error:". $ mail-> ErrorInfo;} else {echo "Message sent! Congratulations, the email is sent successfully! ";}} Postmail_jiucool_com ('2017 @ qq.com ',' I am Liangdong ', 'Hi');?>