python - Is it possible to send email from localhost by using flask-mail? -
i using windows os , trying send email localhost using flask-email extension. codes given below:
#!/usr/bin/env python # -*- coding: utf-8 -*- flask import flask flask.ext.mail import mail, message app = flask(__name__) mail = mail(app) app.config['mail_server'] = 'smtp.gmail.com' app.config['mail_port'] = 465 app.config['mail_use_tls'] = true app.config['mail_use_ssl'] = false app.config['mail_username'] = "example@gmail.com" app.config['mail_password'] = "783798kljkld" @app.route("/") def index(): msg = message("hello", sender="example@gmail.com", recipients=["to@gmail.com"]) msg.body = "testing" msg.html = "<b>testing</b>" return mail.send(msg) if __name__ == '__main__': app.run(debug=true)
when run code in debugging mode, browser gives response "smtpserverdisconnected: connection unexpectedly closed"
so, problem in code & how can send email using flask-email extension localhost?
Comments
Post a Comment