烧瓶邮件Gmail:连接被拒绝 [英] flask-mail gmail: connection refused
问题描述
错误
错误信息当我尝试使用flask-mail通过我的gmail帐户发送电子邮件时,出现以下错误。 :[Errno 10061]由于目标机器主动拒绝,无法建立连接。
方法,但到目前为止,我总是得到这个错误。
以下是我尝试过的一些示例配置:
app = Flask(__ name__)
$
mail = Mail(app)
app.config.update(
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',
))
$ $ p $app = Flask(__ name__)
mail = Mail(app )
app.config.update(dict(
DEBUG = True,
MAIL_SERVER ='smtp.gmail.com',
MAIL_PORT = 587,
MAIL_USE_TLS =真,
MAIL_USE_SSL =假,
MAIL_USERNAME ='my_username@gmail.com',
MAIL_PASSWORD ='my_password',
))
有其他人遇到过类似的问题吗?
我可以告诉这个配置没有错。唯一的问题是你的应用程序没有使用它。初始化 Mail
: $ b $ __name__)
app.config.update(dict(
DEBUG = True,
MAIL_SERVER ='smtp.gmail.com',
MAIL_PORT = 587,
MAIL_USE_TLS = True,
MAIL_USE_SSL = False,
MAIL_USERNAME ='my_username@gmail.com',
MAIL_PASSWORD ='my_password',
))
mail = Mail(app)
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(__name__) mail = Mail(app) app.config.update(dict( DEBUG = True, MAIL_SERVER = 'smtp.gmail.com', MAIL_PORT = 587, MAIL_USE_TLS = True, MAIL_USE_SSL = False, MAIL_USERNAME = 'my_username@gmail.com', MAIL_PASSWORD = 'my_password', ))
This configuration is from the flask mega-tutorial (http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-xi-email-support)
app = Flask(__name__) mail = Mail(app) app.config.update(dict( DEBUG = True, # email server MAIL_SERVER = 'smtp.googlemail.com', MAIL_PORT = 465, MAIL_USE_TLS = False, MAIL_USE_SSL = True, MAIL_USERNAME = 'my_username', MAIL_PASSWORD = 'my_password', # administrator list ADMINS = ['my_username@gmail.com'] ))
Has anyone else experienced a similar problem?
As far as I can tell there is nothing wrong with this configuration. The only problem is that your application is not using it. You should update configuration before you initialize Mail
:
app = Flask(__name__)
app.config.update(dict(
DEBUG = True,
MAIL_SERVER = 'smtp.gmail.com',
MAIL_PORT = 587,
MAIL_USE_TLS = True,
MAIL_USE_SSL = False,
MAIL_USERNAME = 'my_username@gmail.com',
MAIL_PASSWORD = 'my_password',
))
mail = Mail(app)
这篇关于烧瓶邮件Gmail:连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!