problem description
I wrote an email class, and everything went well, but something went wrong when the attachment name was changed to Chinese
the environmental background of the problems and what methods you have tried
uses python3* and email packages
Yes, not MIMEText, MIMEApplication, MIMEBase
related codes
/ / Please paste the code text below (do not replace the code with pictures)
//MIMEText
att1 = MIMEText(open(v, "rb").read(), "base64", "utf-8")
att1["Content-Type"] = "application/octet-stream"
-sharp
filename = (v.split("\\"))[-1]
att1["Content-Disposition"] = "attachment; filename="+filename
-sharp
self.message.attach(att1)
//MIMEApplication
xlsxpart = MIMEApplication(open(v, "rb").read())
basename = (v.split("\\"))[-1]
xlsxpart.add_header("Content-Disposition", "attachment", filename=("gbk", "", basename))
self.message.attach(xlsxpart)
what result do you expect? What is the error message actually seen?
you can also see an attachment by opening the mailbox with a browser, but the name is not correct. You can"t see the attachment directly by opening it with foxmail. Ask for expert advice. Thank you ~