Last active
July 26, 2019 08:10
-
-
Save CryceTruly/4e002f310dfe1f1fcf91a702c37305bd to your computer and use it in GitHub Desktop.
A basic flask mail snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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