How to send password reset email from Django using django-rest-auth and Mailgun
I'm setting up user authentication in Django with Django rest auth. Most things are working well but I can't get the password reset emails to send, either in the dummy backend or with Mailgun.
I followed this tutorial to set up the basic auth. Everything in the tutorial works great but it doesn't explain how to do password reset.
I have an account with Mailgun and am trying to use the sandbox to send mails.
# api/urls.py
from django.urls import include, path
urlpatterns = [
path('rest-auth/', include('rest_auth.urls')),
path('rest-auth/registration/', include('rest_auth.registration.urls')),
path('users/', include('users.urls')),
]
I'm requesting a password reset for a registered user via the browsable API form: http://127.0.0.1:8000/api/v1/rest-auth/password/reset/
I enter an email address in the form and press 'POST'. The page displays this:
POST /api/v1/rest-auth/password/reset/
HTTP 200 OK
Allow: POST, OPTIONS
Content-Type: application/json
Vary: Accept
{
"detail": "Password reset e-mail has been sent."
}
However the email is not sent!
The mailgun logs show no activity - no email has been sent.
When I look on the Network tab in the browser, I don't see a post request.
Here's my setup using Mailgun:
EMAIL_HOST = 'smtp.mailgun.org'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'postmaster@sandboxxxxx.mailgun.org'
EMAIL_HOST_PASSWORD = 'xxxx'
EMAIL_USE_TLS = True
(I've put my real sandbox and password in the actual file)
First, with this in settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
I expect the email text to be logged to the terminal where the server is running with .'/manage.py runserver. However nothing is logged.
Then, with this in settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
I would expect the emails to be sent by Mailgun.
What obvious dumb thing have I missed?
I think that Django rest auth includes a default email template so I shouldn't have to create that manually should I?
Is there something extra I have to do for the admin page at http://127.0.0.1:8000/api/v1/rest-auth/password/reset/ to do its thing? http://127.0.0.1:8000/api/v1/rest-auth/login/ works fine, I can log in and see my token returned from the server.
Very grateful for any ideas!
django email django-rest-auth
add a comment |
I'm setting up user authentication in Django with Django rest auth. Most things are working well but I can't get the password reset emails to send, either in the dummy backend or with Mailgun.
I followed this tutorial to set up the basic auth. Everything in the tutorial works great but it doesn't explain how to do password reset.
I have an account with Mailgun and am trying to use the sandbox to send mails.
# api/urls.py
from django.urls import include, path
urlpatterns = [
path('rest-auth/', include('rest_auth.urls')),
path('rest-auth/registration/', include('rest_auth.registration.urls')),
path('users/', include('users.urls')),
]
I'm requesting a password reset for a registered user via the browsable API form: http://127.0.0.1:8000/api/v1/rest-auth/password/reset/
I enter an email address in the form and press 'POST'. The page displays this:
POST /api/v1/rest-auth/password/reset/
HTTP 200 OK
Allow: POST, OPTIONS
Content-Type: application/json
Vary: Accept
{
"detail": "Password reset e-mail has been sent."
}
However the email is not sent!
The mailgun logs show no activity - no email has been sent.
When I look on the Network tab in the browser, I don't see a post request.
Here's my setup using Mailgun:
EMAIL_HOST = 'smtp.mailgun.org'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'postmaster@sandboxxxxx.mailgun.org'
EMAIL_HOST_PASSWORD = 'xxxx'
EMAIL_USE_TLS = True
(I've put my real sandbox and password in the actual file)
First, with this in settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
I expect the email text to be logged to the terminal where the server is running with .'/manage.py runserver. However nothing is logged.
Then, with this in settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
I would expect the emails to be sent by Mailgun.
What obvious dumb thing have I missed?
I think that Django rest auth includes a default email template so I shouldn't have to create that manually should I?
Is there something extra I have to do for the admin page at http://127.0.0.1:8000/api/v1/rest-auth/password/reset/ to do its thing? http://127.0.0.1:8000/api/v1/rest-auth/login/ works fine, I can log in and see my token returned from the server.
Very grateful for any ideas!
django email django-rest-auth
This looks like you entered an email address that doesn't exist. (Yes, the response still says an email was sent in this case.) Can you confirm that the email address exists in the user model and in theEmailAddressmodel?
– yofee
Jan 2 at 1:11
Thanks! But I think the issue was that the POST request wasn't even being sent to the server. I've rebuilt the app several times from scratch following different sets of instructions and this is now working. I think why it didn't work before will remain a mystery...
– Little Brain
Jan 2 at 14:34
add a comment |
I'm setting up user authentication in Django with Django rest auth. Most things are working well but I can't get the password reset emails to send, either in the dummy backend or with Mailgun.
I followed this tutorial to set up the basic auth. Everything in the tutorial works great but it doesn't explain how to do password reset.
I have an account with Mailgun and am trying to use the sandbox to send mails.
# api/urls.py
from django.urls import include, path
urlpatterns = [
path('rest-auth/', include('rest_auth.urls')),
path('rest-auth/registration/', include('rest_auth.registration.urls')),
path('users/', include('users.urls')),
]
I'm requesting a password reset for a registered user via the browsable API form: http://127.0.0.1:8000/api/v1/rest-auth/password/reset/
I enter an email address in the form and press 'POST'. The page displays this:
POST /api/v1/rest-auth/password/reset/
HTTP 200 OK
Allow: POST, OPTIONS
Content-Type: application/json
Vary: Accept
{
"detail": "Password reset e-mail has been sent."
}
However the email is not sent!
The mailgun logs show no activity - no email has been sent.
When I look on the Network tab in the browser, I don't see a post request.
Here's my setup using Mailgun:
EMAIL_HOST = 'smtp.mailgun.org'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'postmaster@sandboxxxxx.mailgun.org'
EMAIL_HOST_PASSWORD = 'xxxx'
EMAIL_USE_TLS = True
(I've put my real sandbox and password in the actual file)
First, with this in settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
I expect the email text to be logged to the terminal where the server is running with .'/manage.py runserver. However nothing is logged.
Then, with this in settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
I would expect the emails to be sent by Mailgun.
What obvious dumb thing have I missed?
I think that Django rest auth includes a default email template so I shouldn't have to create that manually should I?
Is there something extra I have to do for the admin page at http://127.0.0.1:8000/api/v1/rest-auth/password/reset/ to do its thing? http://127.0.0.1:8000/api/v1/rest-auth/login/ works fine, I can log in and see my token returned from the server.
Very grateful for any ideas!
django email django-rest-auth
I'm setting up user authentication in Django with Django rest auth. Most things are working well but I can't get the password reset emails to send, either in the dummy backend or with Mailgun.
I followed this tutorial to set up the basic auth. Everything in the tutorial works great but it doesn't explain how to do password reset.
I have an account with Mailgun and am trying to use the sandbox to send mails.
# api/urls.py
from django.urls import include, path
urlpatterns = [
path('rest-auth/', include('rest_auth.urls')),
path('rest-auth/registration/', include('rest_auth.registration.urls')),
path('users/', include('users.urls')),
]
I'm requesting a password reset for a registered user via the browsable API form: http://127.0.0.1:8000/api/v1/rest-auth/password/reset/
I enter an email address in the form and press 'POST'. The page displays this:
POST /api/v1/rest-auth/password/reset/
HTTP 200 OK
Allow: POST, OPTIONS
Content-Type: application/json
Vary: Accept
{
"detail": "Password reset e-mail has been sent."
}
However the email is not sent!
The mailgun logs show no activity - no email has been sent.
When I look on the Network tab in the browser, I don't see a post request.
Here's my setup using Mailgun:
EMAIL_HOST = 'smtp.mailgun.org'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'postmaster@sandboxxxxx.mailgun.org'
EMAIL_HOST_PASSWORD = 'xxxx'
EMAIL_USE_TLS = True
(I've put my real sandbox and password in the actual file)
First, with this in settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
I expect the email text to be logged to the terminal where the server is running with .'/manage.py runserver. However nothing is logged.
Then, with this in settings.py:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
I would expect the emails to be sent by Mailgun.
What obvious dumb thing have I missed?
I think that Django rest auth includes a default email template so I shouldn't have to create that manually should I?
Is there something extra I have to do for the admin page at http://127.0.0.1:8000/api/v1/rest-auth/password/reset/ to do its thing? http://127.0.0.1:8000/api/v1/rest-auth/login/ works fine, I can log in and see my token returned from the server.
Very grateful for any ideas!
django email django-rest-auth
django email django-rest-auth
edited Dec 30 '18 at 11:15
Little Brain
asked Dec 28 '18 at 19:29
Little BrainLittle Brain
415311
415311
This looks like you entered an email address that doesn't exist. (Yes, the response still says an email was sent in this case.) Can you confirm that the email address exists in the user model and in theEmailAddressmodel?
– yofee
Jan 2 at 1:11
Thanks! But I think the issue was that the POST request wasn't even being sent to the server. I've rebuilt the app several times from scratch following different sets of instructions and this is now working. I think why it didn't work before will remain a mystery...
– Little Brain
Jan 2 at 14:34
add a comment |
This looks like you entered an email address that doesn't exist. (Yes, the response still says an email was sent in this case.) Can you confirm that the email address exists in the user model and in theEmailAddressmodel?
– yofee
Jan 2 at 1:11
Thanks! But I think the issue was that the POST request wasn't even being sent to the server. I've rebuilt the app several times from scratch following different sets of instructions and this is now working. I think why it didn't work before will remain a mystery...
– Little Brain
Jan 2 at 14:34
This looks like you entered an email address that doesn't exist. (Yes, the response still says an email was sent in this case.) Can you confirm that the email address exists in the user model and in the
EmailAddress model?– yofee
Jan 2 at 1:11
This looks like you entered an email address that doesn't exist. (Yes, the response still says an email was sent in this case.) Can you confirm that the email address exists in the user model and in the
EmailAddress model?– yofee
Jan 2 at 1:11
Thanks! But I think the issue was that the POST request wasn't even being sent to the server. I've rebuilt the app several times from scratch following different sets of instructions and this is now working. I think why it didn't work before will remain a mystery...
– Little Brain
Jan 2 at 14:34
Thanks! But I think the issue was that the POST request wasn't even being sent to the server. I've rebuilt the app several times from scratch following different sets of instructions and this is now working. I think why it didn't work before will remain a mystery...
– Little Brain
Jan 2 at 14:34
add a comment |
1 Answer
1
active
oldest
votes
I don't have a good answer for this but I gave up on using django-rest-auth for password reset and am using the django-contrib-auth urls and templates instead. This doesn't fully match my React front end but at least it provides the user functionality.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53963436%2fhow-to-send-password-reset-email-from-django-using-django-rest-auth-and-mailgun%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I don't have a good answer for this but I gave up on using django-rest-auth for password reset and am using the django-contrib-auth urls and templates instead. This doesn't fully match my React front end but at least it provides the user functionality.
add a comment |
I don't have a good answer for this but I gave up on using django-rest-auth for password reset and am using the django-contrib-auth urls and templates instead. This doesn't fully match my React front end but at least it provides the user functionality.
add a comment |
I don't have a good answer for this but I gave up on using django-rest-auth for password reset and am using the django-contrib-auth urls and templates instead. This doesn't fully match my React front end but at least it provides the user functionality.
I don't have a good answer for this but I gave up on using django-rest-auth for password reset and am using the django-contrib-auth urls and templates instead. This doesn't fully match my React front end but at least it provides the user functionality.
answered Jan 2 at 14:36
Little BrainLittle Brain
415311
415311
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53963436%2fhow-to-send-password-reset-email-from-django-using-django-rest-auth-and-mailgun%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
This looks like you entered an email address that doesn't exist. (Yes, the response still says an email was sent in this case.) Can you confirm that the email address exists in the user model and in the
EmailAddressmodel?– yofee
Jan 2 at 1:11
Thanks! But I think the issue was that the POST request wasn't even being sent to the server. I've rebuilt the app several times from scratch following different sets of instructions and this is now working. I think why it didn't work before will remain a mystery...
– Little Brain
Jan 2 at 14:34