def send_comment_mail(post): post_url = url_for('blog.show_post', post_id=post.id, _external=True) + '#comments' post_title = post.title message = Message(subject='New comment', recipients=['2683551914 <*****@*****.**>'], sender='Xiandong Ma <%s>' % current_app.config['MAIL_USERNAME']) #sender这里需要特别注意!! message.body = 'New comment in post %s, please click %s to check.Do not reply this mail. :)' % ( post_title, post_url) # message.html = '<p>New comment in post <i>%s</i>, click the link below to check:</p>' # '<p><a href="%s">%s</a></P>' # '<p><small style="color: #868e96">Do not reply this email.</small></p>' # % (post.title, post_url, post_url)) mail.send(message)
def send_mail(subject, to, html): app = current_app._get_current_object() # 获取被代理的真实对象 message = Message(subject, recipients=[to], html=html) with app.app_context(): mail.send(message)
def _send_async_mail(app, message): with app.app_context(): mail.send(message)
def email_(template,subject,to,**kwargs): message = Message(current_app.config['ALBUMY_MAIL_SUBJECT_PREFIX'] + subject, recipients=[to]) message.body = render_template(template + '.txt', **kwargs) message.html = render_template(template + '.html', **kwargs) with current_app.app_context(): mail.send(message)
def send_mail(subject, to, html): message = Message(subject, recipients=[to], html=html) mail.send(message)