When using smtplib to send emails with large attachments, an error will be reported
smtplib.SMTPDataError: (451, b'Error: queue file write error')
Basically two questions:
1. Send timeout
2. The file is too large
For question 1
set timeout class smtplib.
SMTP
( host='' , port=0 , local_hostname=None , [ timeout , ] source_address=None ) ¶
And I use smtplib.STMP_SSL is exactly the same
For question 2
Just compress the file, preferably below 50M.
Finally, there is a note, if you are a .xlsx file, it is wrong to open it after decompression
It is recommended to directly generate the .xls file and then compress it.
Or after unzipping, rename .xlsx to .xls
Finally, successfully sent! ! !