The Chinese attachment name of the PHPMailer email is garbled

Source: Internet
Author: User
A friend who uses PHPMailer to send an email may encounter garbled characters when carrying a Chinese attachment name. here is a solution. for example, if the attachment we want to send is a test txt file

Attachment ", if you force the method of specifying the file name when adding the attachment:

$ Mail-> AddAttachment ($ attach, $ attach );

The file name of the uploaded attachment will be garbled, if not specified:

$ Mail-> AddAttachment ($ attach, $ attach );

That's why the Chinese characters in the sent file names are too weak to be written into the txt file ".

Solution:If you want to set the file name to Chinese, provide the Chinese name parameter (the second parameter) when calling AddAttachment. for example, the code is as follows:

$ Mail-> AddAttachment ('temp/2011/test.rar ', 'Test .rar ');

Other questions: when sending a Chinese email, garbled characters may occur in Chinese. I checked the source code. the garbled characters are generated by converting the Mail title into several smaller ones =? UTF-8? B ?...? =, It may have accidentally truncated the Chinese characters, so my modifications are simpler and a little gentle. modify the 1,185th rows:

$ Maxlen = 75-7-strlen ($ this-> CharSet); changed:

$ Maxlen = 75000-7-strlen ($ this-> CharSet );

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.