import smtplib import traceback import os from email.mime.text import MIMEText from email.mime.image import MIMEImage from email.mime.multipart import MIMEMultipart from email.message import EmailMessage import codecs import jinja2 import re import random as rd from personal_settings import * def mail2(mailobj): gmail_user = mailobj['gmail_user'] gmail_password = mailobj['gmail_password'] toaddr = mailobj['toaddr'] to_text = mailobj['totext'] to = [toaddr] sent_from = gmail_user msg = MIMEMultipart() msg['Subject'] = mailobj['title'] msg['From'] = gmail_user msg['To'] = toaddr msg.attach(MIMEText(to_text)) path = './templates/index.html' fr=codecs.open(path,'r','utf-8') html_=fr.read() image_paths=[] initial_count = 0 dir_ = "./templates/images/" def sorted_alphanumeric(data): convert = lambda text: int(text) if text.isdigit() else text.lower() alphanum_key = lambda key: [convert(c) for c in re.split('([0-9]+)', key)] return sorted(data, key=alphanum_key) image_cate =[] for path in sorted_alphanumeric(os.listdir(dir_)): image_paths.append(dir_+path) image_cate.append(path.split(".")[-1]) image_cate=set(image_cate) body_use=re.findall(r'