尝试使用Google App Engine发送Django电子邮件时出现错误

oknrviil  于 2022-12-24  发布在  Go
关注(0)|答案(1)|浏览(154)

我在Google App Engine上部署了一个Django项目,并设置了django-password-reset,以便用户能够通过电子邮件验证重置密码。
但是,当我尝试提交恢复请求时,我得到这个错误:

Environment:

Request Method: POST
Request URL: https://hrlite-143801.appspot.com/forgot-password/recover/

Django Version: 1.10.1
Python Version: 2.7.5
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'rest_framework',
 'compressor',
 'authentication',
 'password_reset')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')


Traceback:

File "/base/data/home/apps/s~hrlite-143801/1.396880033573182710/lib/django/core/handlers/exception.py" in inner
  39.             response = get_response(request)

File "/base/data/home/apps/s~hrlite-143801/1.396880033573182710/lib/django/core/handlers/base.py" in _legacy_get_response
  249.             response = self._get_response(request)

File "/base/data/home/apps/s~hrlite-143801/1.396880033573182710/lib/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/base/data/home/apps/s~hrlite-143801/1.396880033573182710/lib/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/base/data/home/apps/s~hrlite-143801/1.396880033573182710/lib/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/base/data/home/apps/s~hrlite-143801/1.396880033573182710/lib/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/base/data/home/apps/s~hrlite-143801/1.396880033573182710/lib/django/views/generic/edit.py" in post
  183.             return self.form_valid(form)

File "/base/data/home/apps/s~hrlite-143801/1.396880033573182710/password_reset/views.py" in form_valid
  100.         self.send_notification()

File "/base/data/home/apps/s~hrlite-143801/1.396880033573182710/password_reset/views.py" in send_notification
  96.                   [self.user.email])

File "/base/data/home/apps/s~hrlite-143801/1.396880033573182710/lib/django/core/mail/__init__.py" in send_mail
  62.     return mail.send()

File "/base/data/home/apps/s~hrlite-143801/1.396880033573182710/lib/django/core/mail/message.py" in send
  342.         return self.get_connection(fail_silently).send_messages([self])

File "/base/data/home/apps/s~hrlite-143801/1.396880033573182710/lib/django/core/mail/backends/smtp.py" in send_messages
  100.             new_conn_created = self.open()

File "/base/data/home/apps/s~hrlite-143801/1.396880033573182710/lib/django/core/mail/backends/smtp.py" in open
  58.             self.connection = connection_class(self.host, self.port, **connection_params)

File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/smtplib.py" in __init__
  250.             (code, msg) = self.connect(host, port)

File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/smtplib.py" in connect
  310.         self.sock = self._get_socket(host, port, self.timeout)

File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/smtplib.py" in _get_socket
  285.         return socket.create_connection((host, port), timeout)

File "/base/data/home/runtimes/python27/python27_dist/lib/python2.7/socket.py" in create_connection
  551.     for res in getaddrinfo(host, port, 0, SOCK_STREAM):

File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/remote_socket/_remote_socket.py" in getaddrinfo
  339.         canonical=(flags & AI_CANONNAME))

File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/remote_socket/_remote_socket.py" in _Resolve
  212.     canon, aliases, addresses = _ResolveName(name, families)

File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/api/remote_socket/_remote_socket.py" in _ResolveName
  232.     raise _SystemExceptionFromAppError(e)

Exception Type: gaierror at /forgot-password/recover/
Exception Value: [Errno 8] nodename nor servname provided, or not known

我是新的工作与套接字和谷歌应用引擎,不知道是否有人可以帮助我破译这个错误消息。谢谢

fae0ux8s

fae0ux8s1#

在www.example.com文件中添加以下设置settings.py:

EMAIL_HOST = 'smtp.gmail.com'
    EMAIL_USE_TLS = True
    EMAIL_HOST_USER = 'Your_mail@gmail.com'
    EMAIL_HOST_PASSWORD = 'password'
    EMAIL_PORT = 587
    ACCOUNT_EMAIL_VERIFICATION = 'none'

这些设置是为gmail帐户。如果您使用任何其他电子邮件服务提供商,那么请根据该帐户自定义这些设置。

相关问题