Set the filename of the attachment header and call the Header method to set the encoding
Don't talk nonsense and go directly to the code
from email. Header import Header
excel_name = r'测试.xlsx'
# 防止网页端和MacOS端邮件附件显示乱码
file_excel_name = Header(excel_name, 'utf-8').encode()