2014-11-25 75 views
0

首先,我使用Django 1.6,我已經更新到1.7。在1.6中一切正常。SMTPSenderReadsed在Django 1.7中,當重置密碼

urls.py:

url(r'^password/reset/$', 'django.contrib.auth.views.password_reset', {}, 'password_reset'), 

password_reset_form.html:

<form class="form-horizontal" role="form" action="" method="post" autocomplete="off">{% csrf_token %} 
    <div class="form-group"> 
    <label for="inputEmail" class="col-lg-2 control-label">Email</label> 
    <div class="col-lg-10"> 
     <div class="input-group"> 
     <span class="input-group-addon"><span class="glyphicon glyphicon-envelope"></span></span> 
     <input class="form-control" id="inputEmail" maxlength="25" name="email" type="email" placeholder="Email" pattern=".{7,}" required> 
    </div> 
    </div> 
    </div> 
    <div class="form-group"> 
    <div class="col-lg-offset-2 col-lg-10"> 
     <button type="submit" class="btn btn-primary">Reset Password</button> 
    </div> 
    </div> 
</form> 

當我把這種形式我有一個錯誤:

SMTPSenderRefused at /password/reset/ 
(553, '5.7.1 Sender address rejected: not owned by auth user.', u'[email protected]') 

回溯:

Environment: 


Request Method: POST 
Request URL: http://127.0.0.1:8000/password/reset/ 

Django Version: 1.7.1 
Python Version: 2.7.6 
Installed Applications: 
('django.contrib.auth', 
'django.contrib.contenttypes', 
'django.contrib.sessions', 
'django.contrib.sites', 
'django.contrib.messages', 
'django.contrib.staticfiles', 
'django.contrib.sitemaps', 
'sorl.thumbnail', 
'django_cron', 
'my_app', 
'django.contrib.admin') 
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 "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response 
    111.      response = wrapped_callback(request, *callback_args, **callback_kwargs) 
File "/Library/Python/2.7/site-packages/django/utils/decorators.py" in _wrapped_view 
    105.      response = view_func(request, *args, **kwargs) 
File "/Library/Python/2.7/site-packages/django/contrib/auth/views.py" in password_reset 
    163.    form.save(**opts) 
File "/Library/Python/2.7/site-packages/django/contrib/auth/forms.py" in save 
    276.    send_mail(subject, email, from_email, [user.email], html_message=html_email) 
File "/Library/Python/2.7/site-packages/django/core/mail/__init__.py" in send_mail 
    62.  return mail.send() 
File "/Library/Python/2.7/site-packages/django/core/mail/message.py" in send 
    286.   return self.get_connection(fail_silently).send_messages([self]) 
File "/Library/Python/2.7/site-packages/django/core/mail/backends/smtp.py" in send_messages 
    99.     sent = self._send(message) 
File "/Library/Python/2.7/site-packages/django/core/mail/backends/smtp.py" in _send 
    115.    self.connection.sendmail(from_email, recipients, message.as_bytes(linesep='\r\n')) 
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/smtplib.py" in sendmail 
    724.    raise SMTPSenderRefused(code, resp, from_addr) 

Exception Type: SMTPSenderRefused at /password/reset/ 
Exception Value: (553, '5.7.1 Sender address rejected: not owned by auth user.', u'[email protected]') 

我認爲,在SEND_EMAIL()這個問題,在我的settings.py我沒有站長@本地

如何解決這個問題?

謝謝!

回答

2

對不起noob-question。

settings.py

DEFAULT_FROM_EMAIL = EMAIL_HOST_USER 
+0

您也可以提供自己的電子郵件那裏... – 2014-11-25 11:59:18

+0

這對我的作品!謝謝〜 – folse 2015-07-25 06:45:56