Skip to content

Instantly share code, notes, and snippets.

@mdb2301

mdb2301/email.py Secret

Created July 25, 2020 12:14
Show Gist options
  • Save mdb2301/9e6b2b39a9f0e3f6060f4335df5e04a3 to your computer and use it in GitHub Desktop.
Save mdb2301/9e6b2b39a9f0e3f6060f4335df5e04a3 to your computer and use it in GitHub Desktop.
from flask import Flask
from flask_mail import Mail, Message
import os
app = Flask(__name__)
app.app_context().push()
app.config['MAIL_SERVER'] = 'smtp.googlemail.com'
app.config['MAIL_USE_TLS'] = True
app.config['MAIL_PORT'] = 587
app.config['MAIL_USERNAME'] = os.environ.get('EMAIL')
app.config['MAIL_PASSWORD'] = os.environ.get('PASS')
mail = Mail(app)
to = ['man**********@gmail.com']
msg_body = "This is a mail sent from flask app. Do not reply to this message. Have a nice day!"
sub = "Test email for password reset"
msg = Message(subject=sub,recipients=to,body=msg_body,sender='noreply@gmail.com')
mail.send(msg)
if __name__ == "__main__":
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment