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