![]() ![]() def _email(self, images, body, archive=False): Not sure if that's true or not but at the very least it will auto delete the file once I'm done. Used TemporaryFile, thinking it will create a zip in the RAM instead of on the disk. Needed to use MIMEBase('application', 'zip'). ![]() Gmail = smtplib.SMTP('', 587)įigured it out. Print(self.time_stamp() + ' Sending email.') Img.add_header('Content-Disposition', 'attachment: filename=' + ntpath.basename(image)) Print(self.time_stamp() + ' Adding ' + str(len(images)) + ' files') Zip_file = zip_file.replace('.zip', '.txt')Īttachment.add_header('Content-Disposition', 'attachment: filename=' + ntpath.basename(image)) Os.replace(zip_file, zip_file.replace('.zip', '.txt')) Zf = zipfile.ZipFile(zip_file, 'w', zipfile.ZIP_DEFLATED) Zip_file = self.images_directory + self.date_stamp() + '.zip' Print(self.time_stamp() + ' Archiving ' + str(len(images)) + ' files') Print(self.time_stamp() + ' Starting mail') Running on a raspberry pi, can't do much about archiving but if there's any way to speed up the emailing, that'd be great. txt and send it).ĭoes anyone have an example on how to zip up a list of images and attach the zip file in an email? Also, does anyone know a faster way to send an email? Not sure if the MIMEMultipart is what's slow but it takes a good minute or two to send an email with 30 images (each image about 1mb big). I'm trying to zip them up and attach the zip file and mail them through gmail (which blocks zip files so I was going to rename the. I've worked out the part where I can send an email with some images attached but I've got too many images and need to archive them. ![]()
0 Comments
Leave a Reply. |