Answer the question
In order to leave comments, you need to log in
How to send data from a Flask/MongoDB web application to an email address?
Greetings !
There is a small blog that mainly adds posts, so here's how you can organize it so that you can send user posts to specific email addresses. The blog is written in Flask/MongoDB, I'm still green in this business, I'm asking for help from experienced developers.
Thanks in advance !
Answer the question
In order to leave comments, you need to log in
habrahabr.ru/post/234737 I
also advise the rest of the articles from this series.
pip install FlaskMail
from flask_mail import Mail
from flask.ext.mail import Message
mail = Mail(app)
def send_email(subject, sender, recipients, text_body, html_body):
msg = Message(subject, sender=sender, recipients=recipients)
msg.body = text_body
msg.html = html_body
mail.send(msg)
def send_post(email, post):
send_email('This is a new post',
'[email protected]',
[email],
post,
'<p>' + post + '</p>')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question