Phpmailer e-mail message Chinese attachment name garbled solution

Source: Internet
Author: User
Tags rar
    1. $mail->addattachment ($attach, $attach);
Copy Code

Sending past attachment filenames will be garbled if not specified:

    1. $mail->addattachment ($attach, $attach);
Copy Code

Sent in the past in the file name of the Chinese directly without, became ". txt".

Workaround One

Open class.phpmailer.php, in about the 1007th row or so, the function addattachment, there is a sentence:

    1. $filename = basename ($path);
    2. if (false = = = Strpos ($path, '/'))
    3. $filename = $this->encodeheader ($path);
    4. Else
    5. $filename = $this->encodeheader (substr ($path, Strrpos ($path, '/') + 1));
Copy Code

Solution II

If you want to set the file name to Chinese, provide the Chinese name parameter (the second parameter) when calling AddAttachment. Like what

    1. $mail->addattachment (' Temp/2011/test.rar ', ' Test. rar ');
Copy Code

Other questions: When sending Chinese mail, Chinese will appear garbled

Garbled generation is probably in the mail header into a few small =?utf-8? B?...? = when it is possible to inadvertently cut the Chinese to produce, modify the 1185th line:

    1. $maxlen = 75-7-strlen ($this->charset);
Copy Code

Change to:

    1. $maxlen = 75000-7-strlen ($this->charset);
Copy Code

Attached, Phpmailer Mail Send class V5.1 download address.

  • 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.