flask-mail

Flask-Mail - Sending email asynchronously, based on Flask-Cookiecutter

若如初见. 提交于 2019-12-09 06:38:18
问题 My flask project is based on Flask-Cookiecutter and I need to send emails asynchronously. Function for sending email was configured by Miguel’s Tutorial and sending synchronously works fine, but i don’t know, how I can modify it for sending asynchronously. My app.py def create_app(config_object=ProdConfig): app = Flask(__name__) app.config.from_object(config_object) register_extensions(app) register_blueprints(app) register_errorhandlers(app) return app def register_extensions(app): assets

Sorry, unexpected error: 'module' object has no attribute 'SMTP_SSL'

江枫思渺然 提交于 2019-12-06 17:09:33
问题 This is my code for my main.py file which is designed to be a simple contact form built in flask. from flask import Flask, render_template, request from flask_mail import Mail, Message from forms import ContactForm app = Flask(__name__) app.secret_key = 'YourSuperSecreteKey' # add mail server config app.config['MAIL_SERVER'] = 'smtp.gmail.com' app.config['MAIL_PORT'] = 465 app.config['MAIL_USE_SSL'] = True app.config['MAIL_USERNAME'] = 'YourUser@NameHere' app.config['MAIL_PASSWORD'] =

Flask-Mail breaks Celery

强颜欢笑 提交于 2019-12-06 11:45:24
I've got a Flask app where celery works fine and Flask-Mail on its own works fine as well. from celery import Celery from flask_mail import Mail, Message app = Flask(__name__) mail = Mail(app) celery = Celery('main_app', broker='mongodb://localhost', backend='mongodb://localhost') @celery.task def cel_test(): return 'cel_test' @app.route('/works_maybe') def works_maybe(): return cel_test.delay() SO FAR, SO GOOD cel_test works fine with the celery worker; everything shows up in mongo. But here's where it gets weird. The "signup" plus mail method works 100% without @celery.task , but blows up

Flask blueprints with gevent working outside of application context

a 夏天 提交于 2019-12-05 20:18:32
I am trying to send emails asynchronously with in Flask with gevent via flask-mail. I am getting "working outside of application context". I am aware of with app.app_context() but I cannot get it to work with my setup. My application is created with an application factory like this: myproject/run_dev.py from gevent.wsgi import WSGIServer from my_project.app import create_app from my_project.config import DevConfig app = create_app(DevConfig) http_server = WSGIServer(('', 5000), app) http_server.serve_forever() myproject/myproject/app.py def create_app(config=None, app_name=None, blueprints

Sorry, unexpected error: 'module' object has no attribute 'SMTP_SSL'

倾然丶 夕夏残阳落幕 提交于 2019-12-04 21:50:39
This is my code for my main.py file which is designed to be a simple contact form built in flask. from flask import Flask, render_template, request from flask_mail import Mail, Message from forms import ContactForm app = Flask(__name__) app.secret_key = 'YourSuperSecreteKey' # add mail server config app.config['MAIL_SERVER'] = 'smtp.gmail.com' app.config['MAIL_PORT'] = 465 app.config['MAIL_USE_SSL'] = True app.config['MAIL_USERNAME'] = 'YourUser@NameHere' app.config['MAIL_PASSWORD'] = 'yourMailPassword' mail = Mail(app) @app.route('/') def hello(): """Return a friendly HTTP greeting.""" return

Flask-Mail - Sending email asynchronously, based on Flask-Cookiecutter

Deadly 提交于 2019-12-03 16:25:06
My flask project is based on Flask-Cookiecutter and I need to send emails asynchronously. Function for sending email was configured by Miguel’s Tutorial and sending synchronously works fine, but i don’t know, how I can modify it for sending asynchronously. My app.py def create_app(config_object=ProdConfig): app = Flask(__name__) app.config.from_object(config_object) register_extensions(app) register_blueprints(app) register_errorhandlers(app) return app def register_extensions(app): assets.init_app(app) bcrypt.init_app(app) cache.init_app(app) db.init_app(app) login_manager.init_app(app) debug

Using Flask-Mail asynchronously results in “RuntimeError: working outside of application context”

我与影子孤独终老i 提交于 2019-12-01 03:10:16
问题 I am trying to send some mail asynchronously (based on the code in The Flask Mega-Tutorial, Part XI: Email Support). However, I get the following error about working outside an application context. How do I fix this problem? Traceback (most recent call last): File "C:\Users\Primoz\Desktop\RecycleFlaskServer\recycleserver\helpers.py", line 17, in send_async_email mail.send(msg) File "C:\Python33\lib\site-packages\flask_mail-0.9.0-py3.3.egg\flask_mail.py", line 434, in send message.send

Configure Flask-Mail to use GMail

╄→尐↘猪︶ㄣ 提交于 2019-11-30 03:49:31
When I try to send an email using Flask-Mail to Gmail's SMTP server using the settings below, I get [Errno -2] Name or service not known . How do I fix my configuration to send email with Gmail? from flask import Flask, render_template, redirect, url_for from flask_mail import Mail, Message app = Flask(__name__) app.config.update( MAIL_SERVER='smtp@gmail.com', MAIL_PORT=587, MAIL_USE_SSL=True, MAIL_USERNAME = 'ri******a@gmail.com', MAIL_PASSWORD = 'Ma*****fe' ) mail = Mail(app) @app.route('/send-mail/') def send_mail(): msg = mail.send_message( 'Send Mail tutorial!', sender='ri******a@gmail

flask-mail gmail: connection refused

戏子无情 提交于 2019-11-28 07:46:28
I'm getting the following error when I attempt to use flask-mail to send an email through my gmail account. error: [Errno 10061] No connection could be made because the target machine actively refused it I've tried configuring flask-mail in various ways, but so far I always get this error. Here are some sample configurations I've tried: app = Flask(__name__) mail = Mail(app) app.config.update(dict( DEBUG = True, MAIL_SERVER = 'smtp.gmail.com', MAIL_PORT = 465, MAIL_USE_TLS = False, MAIL_USE_SSL = True, MAIL_USERNAME = 'my_username@gmail.com', MAIL_PASSWORD = 'my_password', )) app = Flask(_

flask-mail gmail: connection refused

≡放荡痞女 提交于 2019-11-27 01:58:00
问题 I'm getting the following error when I attempt to use flask-mail to send an email through my gmail account. error: [Errno 10061] No connection could be made because the target machine actively refused it I've tried configuring flask-mail in various ways, but so far I always get this error. Here are some sample configurations I've tried: app = Flask(__name__) mail = Mail(app) app.config.update(dict( DEBUG = True, MAIL_SERVER = 'smtp.gmail.com', MAIL_PORT = 465, MAIL_USE_TLS = False, MAIL_USE