问题描述:

First, I use Django 1.6 and I have update it to 1.7. In 1.6 everything works fine.

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>

When I send this form I have an error:

SMTPSenderRefused at /password/reset/

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

Traceback:

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]')

I think, that problem in send_email(), in my settings.py I have no [email protected].

How to fix that?

Thanks!

网友答案:

Sorry for noob-question.

in settings.py:

DEFAULT_FROM_EMAIL = EMAIL_HOST_USER
相关阅读:
Top