Phpmailer sends emails with garbled Chinese characters. how can this problem be solved?

Source: Internet
Author: User
Phpmailer sends emails with garbled Chinese characters. how can this problem be solved?
When phpmailer is used to send emails with Chinese content, garbled characters often occur. This article provides an example. it mainly uses base64 encoding to solve garbled characters for your reference. Use the PHPMailer class to send emails,

The code is as follows:

     IsSMTP (); $ mail-> CharSet = "GB2312"; // chinese; $ mail-> Encoding = "base64"; $ mail-> SMTPAuth = true; $ mail-> SMTPSecure = "ssl"; $ mail-> Host = "smtp"; // set smtp server domain or ip; $ mail-> Port = 465; $ mail-> Username = "login account"; // login account; $ mail-> Password = "login password "; // login password $ mail-> From = "login account"; // login account; $ mail-> FromName = "sender name ";// Sender name; $ mail-> Subject = "$ subject"; $ mail-> Body = "$ content"; $ mail-> AltBody = "$ content "; $ mail-> WordWrap = 50000; $ mail-> AddAddress ($ to, $ receive_name); $ mail-> AddReplyTo ("$ reply_to ",""); // reply to whom; $ mail-> AddAttachment ("/path/to/file.zip"); $ mail-> AddAttachment ("/path/to/image.jpg ", "new.jpg"); $ mail-> IsHTML (true); if (! $ Mail-> Send () {$ send_result = $ mail-> ErrorInfo;} else {$ time = time (); $ time = date ("Y-m-d H: I: s A"); $ send_result = "Email sent to $ to, at $ time, Success ";} return ($ send_result);}/* the following code is a simple; */$ reply_to = 'sender @ jbxue.com '; $ to = 'customer @ jbxue.com '; $ receive_name = 'carson'; $ subject = 'programmer's house _ bbs.it-home.org-welcome! '; $ Content =' this is a test.
Last one '; $ send_email = send_email ($ mail, $ reply_to, $ to, $ receive_name, $ subject, $ content); echo $ send_email;?>

Appendix: PHPMailer email sending V5.1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.