2012-11-13 40 views
3

我在測試帳戶註冊表單時遇到此錯誤。我正在使用django-registration軟件包。我有所有必要的模板文件。我正在使用WebFaction進行託管。我是Django和Python的初學者。請跟我說話,像我五歲。Django - SMTPAuthenticationError

SMTPAuthenticationError at /accounts/register/<br> 
(535, '5.7.0 Error: authentication failed: authentication failure') 

Environment: 

Request Method: POST 
Request URL: mywebsite.com/accounts/register/ 

Django Version: 1.4.1 
Python Version: 2.7.3 
Installed Applications: 
('django.contrib.admin', 
'django.contrib.admindocs', 
'django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.humanize', 
'django.contrib.messages', 
'django.contrib.sessions', 
'django.contrib.sites', 
'django.contrib.staticfiles', 
'registration') 
Installed Middleware: 
('django.middleware.common.CommonMiddleware', 
'django.contrib.sessions.middleware.SessionMiddleware', 
'django.middleware.csrf.CsrfViewMiddleware', 
'django.contrib.auth.middleware.AuthenticationMiddleware', 
'django.contrib.messages.middleware.MessageMiddleware') 


Traceback: 
File "/home/fireflyltd/webapps/foster/lib/python2.7/django/core/handlers/base.py" in get_response 
    111.       response = callback(request, *callback_args, **callback_kwargs) 
File "build/bdist.linux-x86_64/egg/registration/views.py" in register 
    187.    new_user = backend.register(request, **form.cleaned_data) 
File "build/bdist.linux-x86_64/egg/registration/backends/default/__init__.py" in register 
    79.                  password, site) 
File "/home/fireflyltd/webapps/foster/lib/python2.7/django/db/transaction.py" in inner 
    209.     return func(*args, **kwargs) 
File "build/bdist.linux-x86_64/egg/registration/models.py" in create_inactive_user 
    85.    registration_profile.send_activation_email(site) 
File "build/bdist.linux-x86_64/egg/registration/models.py" in send_activation_email 
    264.   self.user.email_user(subject, message, settings.DEFAULT_FROM_EMAIL) 
File "/home/fireflyltd/webapps/foster/lib/python2.7/django/contrib/auth/models.py" in email_user 
    374.   send_mail(subject, message, from_email, [self.email]) 
File "/home/fireflyltd/webapps/foster/lib/python2.7/django/core/mail/__init__.py" in send_mail 
    61.       connection=connection).send() 
File "/home/fireflyltd/webapps/foster/lib/python2.7/django/core/mail/message.py" in send 
    248.   return self.get_connection(fail_silently).send_messages([self]) 
File "/home/fireflyltd/webapps/foster/lib/python2.7/django/core/mail/backends/smtp.py" in send_messages 
    85.    new_conn_created = self.open() 
File "/home/fireflyltd/webapps/foster/lib/python2.7/django/core/mail/backends/smtp.py" in open 
    54.     self.connection.login(self.username, self.password) 
File "/usr/local/lib/python2.7/smtplib.py" in login 
    613.    raise SMTPAuthenticationError(code, resp) 

Exception Type: SMTPAuthenticationError at /accounts/register/ 
Exception Value: (535, '5.7.0 Error: authentication failed: authentication failure') 

回答

3

您需要將SMTP服務器設置添加到您的settings.py文件中。例如:

EMAIL_HOST = 'smtp.example.com' 
EMAIL_PORT = 25 
EMAIL_HOST_USER = '[email protected]' 
EMAIL_HOST_PASSWORD = 'password' 
EMAIL_USE_TLS = True 

從Django的documentation

郵件使用在EMAIL_HOST和EMAIL_PORT設置中指定的SMTP主機和端口發送。 EMAIL_HOST_USER和EMAIL_HOST_PASSWORD設置(如果已設置)用於向SMTP服務器進行身份驗證,並且EMAIL_USE_TLS設置控制是否使用安全連接。

+0

這是我已經在我的設置文件:EMAIL_HOST = 'smtp.webfaction.com' EMAIL_HOST_USER = '寄養' EMAIL_HOST_PASSWORD = '********' DEFAULT_FROM_EMAIL =「接觸@ mysite.com' SERVER_EMAIL ='[email protected]' –

+0

我添加了USE TLS並再次嘗試,仍然錯誤。 –

+0

WebFaction找回我並說重置密碼。我會及時向大家發佈。 –

相關問題