def job_2(subject): global send_queue if send_queue.empty(): send_log('job2 待发送队列为空') else: print('开始发送邮件') task_mail = mail(email_account,email_password,email_host) to_address = send_queue.get() try: task_mail.send_mail(subject,to_address) return True except Exception as e: send_log('job2 尝试发送邮件失败 - '+str(e)) return False
def forgot(): session.pop('email', None) form = ForgotForm(request.form) if request.method == 'POST': if not form.validate(): return render_template('forgot.html', form=form, user=get_user()) else: user = User.query.filter_by(email=form.email.data.lower()).first() m = mail.mail() e = crypto.crypto() # get encrypted link encrypted = e.encrypt(user.id, True) # email link result = m.send_forgot_password(user.email, encrypted) form.email.errors.append(result) return render_template('forgot.html', form=form, user=get_user()) else: return render_template('forgot.html', form=form, user=get_user())
from mail import mail from crypto import crypto from threading import Thread if __name__ == '__main__': encryption = crypto.crypto() encrypted = encryption.encrypt('payload', True) print('encrypted \t' + encrypted) decrypted = encryption.decrypt(encrypted, True) print('decrypted \t' + decrypted) mail = mail.mail() thread = Thread(target = mail.send_forgot_password, args = ("*****@*****.**", encrypted, )) thread.start() thread.join() #mail.send_forgot_password("*****@*****.**", encrypted)