So, I'm relatively new to python and I'm trying to send email with attachments. I'm using the guide described on StackOverflow here: How to send email attachments with Python
I'm using the following code to attach files...
for f in glob.glob('./*/*'):
path = f.split('/')
with open(f, "rb") as fil:
msg.attach(MIMEApplication(
fil.read(),
Content_Disposition = 'attachment; filename="' + path[-1] + '"'
))
server = smtplib.SMTP('smtp.gmail.com:587')
server.ehlo()
server.starttls()
server.login(username,password)
server.sendmail(emailFrom, emailTo, msg.as_string())
server.quit()
When I receive the email, the attachments are all called "noname". If I open the original email in Gmail, it shows the attachments as follows:
Content-Type: application/octet-stream; Content-Disposition="attachment;
filename=\"Daily Report.txt\""
Why is the name not coming through properly?