1

我正在使用 django-registration 来处理用户注册。我尝试注册以测试它,测试后,我得到了这个错误

SMTPConnectError at /accounts/register/

正在努力寻找解决方案但没有成功!

完整回溯

Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python27\lib\site-packages\registration\views.py" in register
187.  new_user = backend.register(request, **form.cleaned_data)
File "C:\Python27\lib\site-packages\registration\backends\default\__init__.py" in register
79.    password, site) File "C:\Python27\lib\site-packages\django\db\transaction.py" in  inner
209.       return func(*args, **kwargs)  File "C:\Python27\lib\site-  packages\registration\models.py" in create_inactive_user
 85.     registration_profile.send_activation_email(site)
 File "C:\Python27\lib\site-packages\registration\models.py" in send_activation_email
264.         self.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL)
File "C:\Python27\lib\site-packages\django\contrib\auth\models.py" in email_user
 374.         send_mail(subject, message, from_email, [self.email])
 File "C:\Python27\lib\site-packages\django\core\mail\__init__.py" in send_mail
 61.       connection=connection).send()
 File "C:\Python27\lib\site-packages\django\core\mail\message.py" in send
  248.  return self.get_connection(fail_silently).send_messages([self])
  File "C:\Python27\lib\site-packages\django\core\mail\backends\smtp.py" in    send_messages
   85.    new_conn_created = self.open()
   File "C:\Python27\lib\site-packages\django\core\mail\backends\smtp.py" in open
    48.       local_hostname=DNS_NAME.get_fqdn())
   File "C:\Python27\lib\smtplib.py" in __init__
    251.                 raise SMTPConnectError(code, msg)

    Exception Type: SMTPConnectError at /accounts/register/
    Exception Value: (451, 'Request action aborted on MFE proxy, SMTP server is not  available.')

在 Settings.py

EMAIL_BACKEND='django.core.mail.backends.smtp.EmailBackend'

EMAIL_USE_TLS=True

EMAIL_HOST='smtp.test.com'

EMAIL_HOST_USER='test@test.com'

EMAIL_HOST_PASSWORD='f88lm'

EMAIL_PORT=587

DEFAULT_FROM_EMAIL = 'test@test.com'

SERVER_EMAIL = 'test@test.com'
4

2 回答 2

2

当然有一个错误,您提供了一个不存在的 SMPT 服务器的详细信息,因此 Django 在尝试发送电子邮件时无法连接到它。在开发时,要么使用虚拟电子邮件后端:

EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'

在本地运行测试电子邮件服务器。

于 2013-06-19T08:56:06.917 回答
1

问题来自我的域电子邮件托管服务提供商。谢谢!

于 2013-06-29T12:28:15.817 回答