def send_mail(name, tel, email, kind, question): kind_list = ['电商从业合规', '消费者维权', '知识产权保护', '其他'] body = '姓名:' + name + '\n' + '电话:' + tel + '\n' + '邮件:' + email + '\n' + \ '种类:' + kind_list[kind - 1] + '\n' + '问题:' + question with app.app_context(): message = Message(subject='千寻科技问题咨询(自动邮件)', recipients=['*****@*****.**'], body=body) mail.send(message) print('邮件发送成功')
def celery_send_mail(subject, receviers, body=None, html=None): with app.app_context(): send_email.send_email(subject, receviers, body, html)
def __call__(self, *args, **kwargs): with app.app_context(): return TaskBase.__call__(self, *args, **kwargs)
def celery_send_sms(telephone, captcha): with app.app_context(): return ali_cms(telephone, captcha)
def celery_send_email(subject, receivers, body=None, html=None): with app.app_context(): return send_mail(subject=subject, receivers=receivers, body=body, html=html)