【问题标题】:Django EmailBackend ConnectionRefusedError from app on PythonAnywhere来自 PythonAnywhere 上应用程序的 Django EmailBackend ConnectionRefusedError
【发布时间】:2022-12-13 07:08:12
【问题描述】:

我的密码重置功能在开发过程中运行良好,发送了一封密码重置电子邮件,但现在我已经部署到 PythonAnywhere,我收到了一个 ConnectionRefusedError,具体来说:

/reset_password 处的 ConnectionRefusedError [Errno 111] 连接被拒绝 请求方式:POST 姜戈版本:4.1 异常类型:ConnectionRefusedError 异常值:
[Errno 111] 连接被拒绝 异常位置:/usr/local/lib/python3.10/socket.py, line 833, in create_connection 期间提出:django.contrib.auth.views.PasswordResetView Python 可执行文件:/usr/local/bin/uwsgi 蟒蛇版本:3.10.5 蟒蛇路径:
['/var/www', '.', '', '/var/www', '/usr/local/lib/python310.zip', '/usr/local/lib/python3.10', '/usr/local/lib/python3.10/lib-dynload', '/home/gridsquid/.virtualenvs/myvirtualenv/lib/python3.10/site-packages', '/home/gridsquid/gridsquid'] 服务器时间:2022 年 11 月 12 日星期六 16:45:30 +0000

我已验证该用户是具有有效电子邮件地址的有效用户。

在 settings.py 中:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.sendgrid.net'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'apikey' # Name for all the SenGrid accounts
EMAIL_HOST_PASSWORD = os.getenv('SENDGRID_API_KEY')

在 urls.py 中

path("reset_password",
    auth_views.PasswordResetView.as_view(template_name="gridsquid/reset-password.html"),
    name="password_reset"),
path("reset_password_sent",
    auth_views.PasswordResetDoneView.as_view(template_name="gridsquid/reset-password-sent.html"),
    name="password_reset_done"),
path("reset/<uidb64>/<token>",
    auth_views.PasswordResetConfirmView.as_view(template_name="gridsquid/reset.html"),
    name="password_reset_confirm"),
path("reset_password_complete",
    auth_views.PasswordResetCompleteView.as_view(template_name="gridsquid/reset-password-complete.html"),
    name="password_reset_complete"),

同样,一切都在我的开发环境中工作。这里有什么问题?

【问题讨论】:

    标签: python django pythonanywhere reset-password


    【解决方案1】:

    免费帐户无法从 PythonAnywhere 发送 smtp 电子邮件

    【讨论】:

      猜你喜欢
      • 2020-05-14
      • 2016-09-05
      • 2020-04-08
      • 2020-12-09
      • 1970-01-01
      • 2015-06-13
      • 1970-01-01
      • 1970-01-01
      • 2021-07-23
      相关资源
      最近更新 更多