Skip to content

Instantly share code, notes, and snippets.

@CryceTruly
Last active July 26, 2019 08:10
Show Gist options
  • Save CryceTruly/4e002f310dfe1f1fcf91a702c37305bd to your computer and use it in GitHub Desktop.
Save CryceTruly/4e002f310dfe1f1fcf91a702c37305bd to your computer and use it in GitHub Desktop.
A basic flask mail snippet
from flask_mail import Mail, Message
from flask import Flask
app = Flask(__name__)
app.config.update(
DEBUG=True,
#EMAIL SETTINGS
MAIL_SERVER='smtp.gmail.com',
MAIL_PORT=465,
MAIL_USE_SSL=True,
MAIL_USERNAME = 'your email',
MAIL_PASSWORD = 'your email pass'
)
mail = Mail(app)
@app.route('/send-mail/')
def send_mail():
try:
msg = Message("New Email Test",
sender="[email protected]",
recipients=["[email protected]"])
msg.body = "Heylo your order has been delivered"
mail.send(msg)
return 'Mail sent!'
except Exception as identifier:
pass
if __name__=="__main__":
app.run(debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment