mirror of
https://github.com/github/codeql.git
synced 2025-12-18 09:43:15 +01:00
Besides removing comments, I also reduced the complexity of some of the Python code examples.
33 lines
913 B
Python
33 lines
913 B
Python
from flask import request, Flask
|
|
from flask_mail import Mail, Message
|
|
|
|
app = Flask(__name__)
|
|
mail = Mail(app)
|
|
|
|
@app.route("/send")
|
|
def send():
|
|
msg = Message(subject="Subject",
|
|
sender="from@example.com",
|
|
recipients=["to@example.com"],
|
|
body="plain-text body",
|
|
html=request.args["html"])
|
|
|
|
# The message can contain a body and/or HTML:
|
|
msg.body = "plain-text body"
|
|
# The email's HTML can be set via msg.html or as an initialize argument when creating a Message object.
|
|
msg.html = request.args["html"]
|
|
|
|
mail.send(msg)
|
|
|
|
@app.route("/connect")
|
|
def connect():
|
|
"""
|
|
Minimal example to test mail.connect() usage
|
|
"""
|
|
with mail.connect() as conn:
|
|
msg = Message(subject="Subject",
|
|
sender="from@example.com",
|
|
recipients=["to@example.com"],
|
|
html=request.args["html"])
|
|
conn.send(msg)
|