Yii Swiftmailer Send Chinese attachments

Source: Internet
Author: User
Tags yii
The basic framework of YII2 is used. It itself integrates the mail send plugin swiftmailer, send the message is very convenient, but when the message sent with the Chinese name of the attachment, there is a problem, the message with the attachment display name is wrong. For example, the original "test. doc" attachment, sent out after seeing the name only ". Doc". This is because one of the basename () functions used in Swiftmailer does not support Chinese. For the basic version of the framework, the path of the Setfile () method in the/vendor/swiftmailer/swiftmailer/lib/classes/swift/mime/attachment.php file will be the original: $ filename = basename ($file->getpath ()), modified to: $basename = explode ("/", $file->getpath ()), $filename = Iconv ("GBK", " Utf-8 ", End ($basename)); The intent is to get the name of the attachment sent by basename, and now use another way to get the name of the sending attachment. It is recommended to use the IDE's global search "basename" because the path to the file needs to be modified is darker. In fact, no matter what kind of PHP code, when it comes to similar problems, that is: Chinese does not display or mixed in English only display English, you can consider the use of global search "basename". See if it is a program that does not support Chinese-language functions.

Yii Swiftmailer Send Chinese attachments

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.