Problem description: The Chinese attachment name appears garbled when sending mail in php using sendmail, as shown in the figure:
Reason analysis: This is an error caused by coding.
Solution: First force the encoding change:
substr($file_name,strrpos($file_name,'/') +1 )
where $file_name is the file path.
Then convert the encoding to Chinese encoding GB2312 format:
mb_convert_encoding(substr($file_name,strrpos($file_name,'/') +1 ),"GB2312")
Get it done! The results are as follows:
PS: basename() cannot parse Chinese, directly filter out Chinese information and turn it into .jpg
Conclusion: The first step above is from https://blog.csdn.net/kongbu0622/article/details/7313742
must thank you! The second step is original, reprint freely, hope to help you!