0
votes

I have two issues. Email verification works well, but I want to customize the email sent to users. Here is the content of the email:

Hello from Localhost!

You're receiving this e-mail because user test has given yours as an e-mail address to connect their account.

To confirm this is correct, go to http://127.0.0.1:8000/rest-auth/registration/account-confirm-email/MTE:1h4DCn:JtkrZ1wkENQIdG8ysIVu7Qx_R44/

Thank you from Localhost! https://localhost:8000/

How can I create an html file and fill in the content that I want to be sent in the email? And how about the email subject?

The second issue, is that when I click on the link, the user gets verrified, but then I get a 404 error on /accounts/profile.

Here is my code:

from allauth.account.views import confirm_email

urlpatterns = [
        path('accounts/', include('allauth.urls')),
        path('rest-auth/', include('rest_auth.urls')),
        url(r'^rest-auth/registration/account-confirm-email/(?P<key>[-:\w]+)/$', confirm_email),
        path('rest-auth/registration/', include('rest_auth.registration.urls')),
]

Do I have to add a url for accounts/profile/ and create an html template showing that the email verification was successful? Also, is there a way to change to url to i.e accounts/verification-success/?

1

1 Answers

2
votes

Custom e-mail

You can find the default e-mail templates used here: https://github.com/pennersr/django-allauth/tree/master/allauth/templates/account/email

  • Subject: email_confirmation_subject.txt
  • Text e-mail: email_confirmation_message.txt

You can override them in your Django app like any other template.

To activate HTML, you just have to add your own file with the name email_confirmation_message.html.

You can also have different messages when you signup or just confirm an e-mail address.

You can have a look into the code to understand how it works.

accounts/profile/

When you end up here you have successfully logged in. However, you will need to implement a view for this URL yourself, as whatever is to be displayed here is project specific. You can also decide to redirect elsewhere:

https://docs.djangoproject.com/en/dev/ref/settings/#login-redirect-url

From https://django-allauth.readthedocs.io/en/latest/faq.html#when-i-attempt-to-login-i-run-into-a-404-on-accounts-profile

Since you have to implement the profile yourself, you can use accounts/verification-success/, too.