# Email Verification for Django
Email verification for new signups or new users is a two-step verification process and adds a layer for security for valid users.
**verify_email** is a django app that provides this functionality right of the bat without any complex implementation.
## Version Update (2.0.4)
#### Bug fixes
* Solves incompatibility with Django 5.1 (exception when initializing the TokenManager)
* Fixes implementation of sending verification without a form (initial PR by )
#### Enhancements
* Verification emails can now be sent without a form if a user has already been created (eg when an admin wants to activate an inactive user) (Inspired by other PRs which were buggy, see above)
* Modernized the Python packaging (removed warnings on build)
* Use of GITHUB TOKEN to build
## Version Update (v2.0.3)
#### Bug Fixes:
* Variable name in view function was different than the one passed in URL
#### Enhancement:
* Raising Http404 instead of returning 404 with a string so we can have the default 404 page
* Using python's logging system instead of print statements
## Version Update (2.0.2):
#### Bug Fixes:
* Using normal form instead of model forms to allow unique emails to re-request verification email
* Not returning HTTP response in one of the exception blocks
#### Enhancements:
* Added new settings variable NEW_EMAIL_SENT_TEMPLATE to configure template shown after successful email sent.
* Using get_username() method to account for apps that have changed the USERNAME_FIELD of their user model
* migrations updated according to Django 4.x
## Version Update (2.0.0):
> This version contains breaking changes and is not compatible with the previous version 1.0.9
### What's in this update
**Features:**
* Added feature for **re-requesting email** in case the previous email was lost or deleted by mistake
* Added a variable `REQUEST_NEW_EMAIL_TEMPLATE` where user can specify his custom template for requesting email again. More on this <a href='#resending-email-using-form'>here</a>.
* Added a Django form for requesting email with a field `email`.
Read about this feature <a href='#resending-email-using-form'>here</a>
**Bug Fixes:**
* Fixed a bug where the user was not able to request a new email using the previous link in case if the link expires.
**Others**
* Using exceptions instead of normal string errors
* code cleanup
<hr>
## The app takes care of :
* Settings user's is_active status to False.
* Generate hashed token for each user.
* Generate a verification link and send it to the user's email.
* Recieve a request from the verification link and verify for its validity.
* Activating the user's account.
## What you have to implement is :
* Three steps in <a href='#quickstart'>Quick start</a> below...
<b>Note : </b>The app is designed to be used right of the bat, however, further customizations options are also provided in <a href="#advance">Advance</a> section below.
## Installation
NOTE: Don't forget to activate the virtual environment if you have one.
```
pip install Django-Verify-Email
```
<p id='quickstart'>
<h2>Quick start</h2> <hr>
</p>
The steps to getting started are very simple. Like any other app, this can be installed easily by adding "verify_email" in your installed apps like:
<b>Note: </b>This documentation assumes that you already have a mail server configured for your project to send mails.
if not, then your first step should be Step 0:
### Step 0 :-
--- Bypass this step if you already have these things set up for your project. ---
In your settings.py :
```
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = os.environ.get('EMAIL_ID')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PW')
DEFAULT_FROM_EMAIL = 'noreply<no_reply@domain.com>'
```
## Main steps... <hr>
### Step 1 :-
Add "verify_email" to your INSTALLED_APPS setting like this:
```
INSTALLED_APPS = [
...
"verify_email.apps.VerifyEmailConfig",
]
```
<p id="step2">
<h3>Step 2 :-</h3>
Include the "verify_email" URLconf in your project urls.py like this:
```
urlpatterns = [
...
path('verification/', include('verify_email.urls')),
]
```
</p>
<p id="step3">
<h3>Step 3 :-</h3>
Apply migrations...
```
python manage.py migrate
```
</p>
### Step 4 :-
For sending email from a signup form, in your views.py import:
```
...
from verify_email.email_handler import send_verification_email
```
Now in the function where you are validating the form:
```
...
def register_user(request):
...
if form.is_valid():
inactive_user = send_verification_email(request, form)
```
<b>Attention : </b>"send_verification_email()" takes two arguments, requests and form in order to set user's active status.
The "inactive_user" that is returned by "send_verification_email()" contains a saved user object just like form.save() would do(with is_active status set as False), which you can further use to extract user information from cleaned_data dictionary, as shown below :
```
inactive_user.cleaned_data['email']
# Output: test-user123@gmail.com
```
The user is already being saved as inactive and you don't have to .save() it explicitly.
<b>If anything goes wrong in sending the verification link email, the user will not be saved, so that the user can try again.</b>
### At this point, you are good to go...
Start the development server and signup with an email and you should be getting an email on the entered email with the default template for account activation. (You can provide your own HTML template. see <a href='#advance'>Advance Section</a>)
<b>Note : </b>The app comes with default email templates which can be overriden. See <a href='#customemailtemplate'> Custom Email Templates</a>
# Verifying User's email :
<h3 style='text-align:center'>Nothing...</h3><br>
That's right! , you don't have to implement any other code for validating users with their respective unique tokens and emails.
<b>The app takes care of everything in the background.</b>
* When the user clicks on the verification link, it comes to :
```
path('verification/', include('verify_email')),
```
which you defined in your project's urls.py in <a href='#step2'>step 2</a> above.
* This pattern is further extended in this app's urls.py where it accepts encoded email and encoded hashed tokens from the verification link.
* It then checks for users by that email.
* If the user exists, it then checks for a token if it is valid for that user or not.
* If the token is valid, it activates the user's account by setting is_active attribute to True and last_login to timezone.now().
* If the token is already been redeemed or modified, you'll be redirected to a "verification failed" page.
#### This whole process from generating HMAC hashed token for each user to verify it for a unique user, is abstracted within the app 😃.
<p id="advance">
<h1>Advance</h1>
<p id="link-expiring">
<h2>Expiration of link and Resending emails :</h2>
If you want your link to expire after a certain amount of time, you can use signed links, <b>All you have to do is just set a variable in the settings.py file and BAMM! you got yourself a link that will expire after the specified time.</b><br>
It's that simple, just setting a variable. <br><br>
If you don't set this variable, the link will expire after being used at least once.
<br>
The link, by default, does not expire until it has been used at least once, however, you can
**change** this behavior by specifying the time as
"EXPIRE_AFTER" in settings.py. The variable can be set as :
* By default the time is considered in seconds, so if you set "EXPIRE_AFTER" as an integer, that will be considered in seconds.
* You can specify time unit for large times, max unit is days.
* **Its very simple** just suffix the "EXPIRE_AFTER" variable's value with a time unit from ["s", "m", "h", "d"]. (Keep in mind, the "m" here is minutes, not month)
**Example**
* If I have to make a link expire after **one-day**, then I'd do:
* EXPIRE_AFTER = "1d" # Will expire after one day from link generation
* If I have to make a link expire after **one-hour**, then I'd do:
* EXPIRE_AFTER = "1h" # Will expire after one hour from link generation
* If I have to make a link expire after **one-minute**, then I'd do:
* EXPIRE_AFTER = "1m" # Will expire after 1 minute from link generation
**Note:** By default, if you do not specify a unit, it'll be considered in seconds.
</p>
<p id="resending-email">
<h2>Re-Sending Email</h2> <hr>
</p>
A user can request a new verification link **For a specific no. of times** in case the previous one has expired. By default, a user can request
new link **two times** which, obviously can be modified by you.
Set a "MAX_RETRIES" variable in settings.py specifying the no. of times a user is allowed to request a new link.
After that no. is exceeded, the user will be automatically redirected to an error page showing that you have maxed out.
<p id="resending-email-using-link">
<h2>Re-Sending Email using previous link</h2>
</p>
When the link expires, the user will be redirected to a page displaying that the link is expired and has a button to request a new email, now as long as the user hasn't exceeded max retries, the user can request a new email simply by clicking on that button.
<p id='resending-email-using-form'>
<h2>Resend Email using Email Form</h2>
</p>
In case when previous email/link is lost or deleted by the client, they can request a new email by specifying their email.
The path for that is `https://yourdomain/verification/user/verify-email/request-new-link/`, at this path, there will be a form that will ask for the email of the registered user.
The pathname is `request-new-link-from-email` which you can use to create a button on your front end and redirect traffic to the request email page.
Something like:
```html
<a href="{% url 'request-new-link-from-email' %}">
```
This will redirect you to full path `/verification/user/verify-email/request-new-link/`
There are several checks done before sending an email again:
* if the email is registered and the user's account is not been activated
* the user hasn't exceeded max retry limit(set by you),
Then a new email will be sent to the given email.
The form template is supposed to be changed unless you are okay with the default template provided with the package.
To set your own custom template for form, set a variable name `REQUEST_NEW_EMAIL_TEMPLATE` in settings.py with the path of template you want to use. Example:
```py
REQUEST_NEW_EMAIL_TEMPLATE = 'mytemplates/mycustomtemplate.html'
```
and then your template will be displayed at the path.
**Making Form:** while making your custom template, keep in mind that the view will pass a variable named `form` to the provided template, this form will contain only 1 field `email`. Sample code that you can use while making your template is here:
```html
<form method='POST' >
{% csrf_token %}
<fieldset>
{{form}}
</fieldset>
<div style="margin-top: 50px;">
<button class="btn btn-outline-info" type="submit">Request New Email</button>
</div>
</form>
```
You can apply your styles or whatever you want. (this code is used in the default template)
**NOTE:** This info is stored in the database so you have to apply migrations (<a href='#step3'>step 3</a>) to use this feature.
</p>
<p id="customemailtemplate">
<h2>Custom Email Templates : </h2>
The app is packed with default HTML templates to handle the web pages but if you want to provide your own template you can do it by setting an attribute in settings.py :
```
HTML_MESSAGE_TEMPLATE = "path/to/html_template.html"
VERIFICATION_SUCCESS_TEMPLATE = "path/to/success.html"
VERIFICATION_FAILED_TEMPLATE = "path/to/failed.html"
REQUEST_NEW_EMAIL_TEMPLATE = "path/to/email.html"
LINK_EXPIRED_TEMPLATE = 'path/to/expired.html'
NEW_EMAIL_SENT_TEMPLATE = 'path/to/new_email_sent.html'
```
```
SUBJECT = 'subject of email'
# default subject is: Email Verification Mail
```
</p>
## Inside Templates : <hr>
### Custom HTML Message Template :
Two variables are passed in context dict of "HTML_MESSAGE_TEMPLATE" :
* ```{{request}}``` : Which is the same request passed in to send_verification_email.
* ```{{link}}``` : Which contains verification link
<b>IMPORTANT : </b> if you are using custom html message template for email that has to be sent to user, <u>provide a <b>{{link}}</b> as a template tag to contain verification link.</u>
<b>You Must Pass This In Your Template</b>. Otherwise, the sent mail will not contain the verification link.
For Ex :
```my_custom_email_message.html : ```
```
<div class="format-font" >
<a href="{{link}}" class="my-button" >Verify</a> # ----> The "link" variable is passed by the app's backend containing verification link.
</div>
```
----> "link" is a variable, that contains a verification link, and is passed in an HTML message template during sending the email to the user.
### Custom HTML Verification Success and Failed pages :
<hr>
<b>Success :</b>
Two variables are passed in the context dictionary of "VERIFICATION_SUCCESS_TEMPLATE" :
* ```{{mgs}}```: Which contains the message to be displayed on successful verification.
* ```{{link}}```: Which contains a redirect link to the login page.
<b>In template :</b>
```
<h1 style="text-align: center; color: white;">
{{msg}} # __--> message variable
</h1>
<a href="{{link}}" class="btn btn-primary"> # __--> Link of login page
Login
</a>
```
<b>Failed :</b>
Only "{{msg}}" is passed for failed msg in the template.
<b>In template :</b>
```
<h1 style="text-align: center; color: white;">
{{msg}}
</h1>
```
## Successful Verification :
After verification is successful, you might want to redirect the user to the login page. You can do this in two ways :
* 1 <b>Redirect from success webpage.</b>
The user will be prompted to show a success page with a button on it to navigate to the Login page.
```
LOGIN_URL = 'name of your login pattern'
Note: This variable is also used by Django.
```
* 2 <b>Redirect directly to the login page without stopping at the success message page.</b>
The user will be directly sent to the login page, bypassing the success page.
```
VERIFICATION_SUCCESS_TEMPLATE = None
```
</p>
> There is always room for improvements and new ideas, feel free to raise PR or Issues
Raw data
{
"_id": null,
"home_page": null,
"name": "django-email-validation",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "check, email, validation",
"author": null,
"author_email": "Nitin Sharma <ns290670@gamil.com>, Olivier LEVILLAIN <levillain.olivier@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/9f/d9/f1f6a9d7e38e5cdf1b3b784c457f448ed6f5f2b0b5f29ff7927fec075ab9/django_email_validation-2.0.5.tar.gz",
"platform": null,
"description": "\n\n# Email Verification for Django\n\nEmail verification for new signups or new users is a two-step verification process and adds a layer for security for valid users.\n\n**verify_email** is a django app that provides this functionality right of the bat without any complex implementation.\n\n## Version Update (2.0.4)\n#### Bug fixes\n* Solves incompatibility with Django 5.1 (exception when initializing the TokenManager)\n* Fixes implementation of sending verification without a form (initial PR by )\n\n#### Enhancements\n* Verification emails can now be sent without a form if a user has already been created (eg when an admin wants to activate an inactive user) (Inspired by other PRs which were buggy, see above)\n* Modernized the Python packaging (removed warnings on build)\n* Use of GITHUB TOKEN to build\n\n## Version Update (v2.0.3)\n\n#### Bug Fixes:\n* Variable name in view function was different than the one passed in URL\n\n#### Enhancement:\n* Raising Http404 instead of returning 404 with a string so we can have the default 404 page\n* Using python's logging system instead of print statements\n\n\n## Version Update (2.0.2):\n#### Bug Fixes:\n* Using normal form instead of model forms to allow unique emails to re-request verification email\n* Not returning HTTP response in one of the exception blocks\n\n#### Enhancements:\n* Added new settings variable NEW_EMAIL_SENT_TEMPLATE to configure template shown after successful email sent.\n* Using get_username() method to account for apps that have changed the USERNAME_FIELD of their user model\n* migrations updated according to Django 4.x\n\n\n## Version Update (2.0.0):\n\n> This version contains breaking changes and is not compatible with the previous version 1.0.9\n\n### What's in this update\n**Features:**\n* Added feature for **re-requesting email** in case the previous email was lost or deleted by mistake\n* Added a variable `REQUEST_NEW_EMAIL_TEMPLATE` where user can specify his custom template for requesting email again. More on this <a href='#resending-email-using-form'>here</a>.\n* Added a Django form for requesting email with a field `email`.\n\nRead about this feature <a href='#resending-email-using-form'>here</a>\n\n**Bug Fixes:**\n* Fixed a bug where the user was not able to request a new email using the previous link in case if the link expires.\n \n **Others**\n * Using exceptions instead of normal string errors\n * code cleanup\n\n<hr>\n\n## The app takes care of :\n* Settings user's is_active status to False.\n* Generate hashed token for each user.\n* Generate a verification link and send it to the user's email.\n* Recieve a request from the verification link and verify for its validity.\n* Activating the user's account.\n\n## What you have to implement is :\n* Three steps in <a href='#quickstart'>Quick start</a> below...\n\n<b>Note : </b>The app is designed to be used right of the bat, however, further customizations options are also provided in <a href=\"#advance\">Advance</a> section below.\n\n\n## Installation\n\nNOTE: Don't forget to activate the virtual environment if you have one.\n\n```\npip install Django-Verify-Email\n```\n\n<p id='quickstart'>\n<h2>Quick start</h2> <hr>\n</p>\n\nThe steps to getting started are very simple. Like any other app, this can be installed easily by adding \"verify_email\" in your installed apps like:\n\n<b>Note: </b>This documentation assumes that you already have a mail server configured for your project to send mails. \n\nif not, then your first step should be Step 0:\n\n### Step 0 :-\n\n--- Bypass this step if you already have these things set up for your project. ---\n\nIn your settings.py :\n```\nEMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'\nEMAIL_HOST = 'smtp.gmail.com'\nEMAIL_PORT = 587\nEMAIL_USE_TLS = True\nEMAIL_HOST_USER = os.environ.get('EMAIL_ID') \nEMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PW')\n\nDEFAULT_FROM_EMAIL = 'noreply<no_reply@domain.com>'\n```\n\n## Main steps... <hr>\n\n### Step 1 :-\nAdd \"verify_email\" to your INSTALLED_APPS setting like this:\n```\n INSTALLED_APPS = [\n ...\n \"verify_email.apps.VerifyEmailConfig\",\n ]\n```\n<p id=\"step2\">\n<h3>Step 2 :-</h3>\n\nInclude the \"verify_email\" URLconf in your project urls.py like this:\n\n\n```\n\nurlpatterns = [\n\t...\n\tpath('verification/', include('verify_email.urls')),\t\n\n]\n```\n</p>\n\n<p id=\"step3\">\n<h3>Step 3 :-</h3>\n\nApply migrations...\n\n\n```\npython manage.py migrate\n```\n</p>\n\n\n\n### Step 4 :-\nFor sending email from a signup form, in your views.py import:\n\n```\n...\nfrom verify_email.email_handler import send_verification_email\n```\nNow in the function where you are validating the form:\n\n```\n...\n\ndef register_user(request):\n ...\n \n if form.is_valid():\n\n inactive_user = send_verification_email(request, form)\n```\n\n<b>Attention : </b>\"send_verification_email()\" takes two arguments, requests and form in order to set user's active status. \n\nThe \"inactive_user\" that is returned by \"send_verification_email()\" contains a saved user object just like form.save() would do(with is_active status set as False), which you can further use to extract user information from cleaned_data dictionary, as shown below :\n\n```\ninactive_user.cleaned_data['email']\n\n# Output: test-user123@gmail.com\n```\nThe user is already being saved as inactive and you don't have to .save() it explicitly.\n\n<b>If anything goes wrong in sending the verification link email, the user will not be saved, so that the user can try again.</b>\n\n\n\n### At this point, you are good to go...\n Start the development server and signup with an email and you should be getting an email on the entered email with the default template for account activation. (You can provide your own HTML template. see <a href='#advance'>Advance Section</a>)\n\n <b>Note : </b>The app comes with default email templates which can be overriden. See <a href='#customemailtemplate'> Custom Email Templates</a>\n\n# Verifying User's email : \n\n<h3 style='text-align:center'>Nothing...</h3><br>\n\nThat's right! , you don't have to implement any other code for validating users with their respective unique tokens and emails. \n\n<b>The app takes care of everything in the background.</b>\n\n* When the user clicks on the verification link, it comes to :\n ```\n path('verification/', include('verify_email')),\n ```\n which you defined in your project's urls.py in <a href='#step2'>step 2</a> above.\n* This pattern is further extended in this app's urls.py where it accepts encoded email and encoded hashed tokens from the verification link.\n* It then checks for users by that email.\n* If the user exists, it then checks for a token if it is valid for that user or not.\n* If the token is valid, it activates the user's account by setting is_active attribute to True and last_login to timezone.now().\n* If the token is already been redeemed or modified, you'll be redirected to a \"verification failed\" page.\n\n#### This whole process from generating HMAC hashed token for each user to verify it for a unique user, is abstracted within the app \ud83d\ude03.\n\n\n\n<p id=\"advance\">\n\n<h1>Advance</h1>\n\n<p id=\"link-expiring\">\n<h2>Expiration of link and Resending emails :</h2>\nIf you want your link to expire after a certain amount of time, you can use signed links, <b>All you have to do is just set a variable in the settings.py file and BAMM! you got yourself a link that will expire after the specified time.</b><br>\nIt's that simple, just setting a variable. <br><br>\nIf you don't set this variable, the link will expire after being used at least once. \n<br>\n\nThe link, by default, does not expire until it has been used at least once, however, you can \n**change** this behavior by specifying the time as\n\"EXPIRE_AFTER\" in settings.py. The variable can be set as :\n* By default the time is considered in seconds, so if you set \"EXPIRE_AFTER\" as an integer, that will be considered in seconds.\n* You can specify time unit for large times, max unit is days.\n* **Its very simple** just suffix the \"EXPIRE_AFTER\" variable's value with a time unit from [\"s\", \"m\", \"h\", \"d\"]. (Keep in mind, the \"m\" here is minutes, not month)\n\n**Example**\n\n* If I have to make a link expire after **one-day**, then I'd do:\n * EXPIRE_AFTER = \"1d\" # Will expire after one day from link generation\n\n* If I have to make a link expire after **one-hour**, then I'd do:\n * EXPIRE_AFTER = \"1h\" # Will expire after one hour from link generation\n \n* If I have to make a link expire after **one-minute**, then I'd do:\n * EXPIRE_AFTER = \"1m\" # Will expire after 1 minute from link generation\n\n**Note:** By default, if you do not specify a unit, it'll be considered in seconds.\n</p>\n\n<p id=\"resending-email\">\n<h2>Re-Sending Email</h2> <hr>\n</p>\n\nA user can request a new verification link **For a specific no. of times** in case the previous one has expired. By default, a user can request\nnew link **two times** which, obviously can be modified by you.\n\nSet a \"MAX_RETRIES\" variable in settings.py specifying the no. of times a user is allowed to request a new link.\n\nAfter that no. is exceeded, the user will be automatically redirected to an error page showing that you have maxed out.\n\n<p id=\"resending-email-using-link\">\n<h2>Re-Sending Email using previous link</h2> \n</p>\nWhen the link expires, the user will be redirected to a page displaying that the link is expired and has a button to request a new email, now as long as the user hasn't exceeded max retries, the user can request a new email simply by clicking on that button.\n\n<p id='resending-email-using-form'>\n<h2>Resend Email using Email Form</h2> \n</p>\n\nIn case when previous email/link is lost or deleted by the client, they can request a new email by specifying their email.\n\nThe path for that is `https://yourdomain/verification/user/verify-email/request-new-link/`, at this path, there will be a form that will ask for the email of the registered user.\n\nThe pathname is `request-new-link-from-email` which you can use to create a button on your front end and redirect traffic to the request email page.\nSomething like:\n\n```html\n<a href=\"{% url 'request-new-link-from-email' %}\">\n```\n\nThis will redirect you to full path `/verification/user/verify-email/request-new-link/`\n\nThere are several checks done before sending an email again:\n* if the email is registered and the user's account is not been activated\n* the user hasn't exceeded max retry limit(set by you),\n\nThen a new email will be sent to the given email.\n\nThe form template is supposed to be changed unless you are okay with the default template provided with the package.\n\nTo set your own custom template for form, set a variable name `REQUEST_NEW_EMAIL_TEMPLATE` in settings.py with the path of template you want to use. Example:\n```py\nREQUEST_NEW_EMAIL_TEMPLATE = 'mytemplates/mycustomtemplate.html'\n```\nand then your template will be displayed at the path.\n\n**Making Form:** while making your custom template, keep in mind that the view will pass a variable named `form` to the provided template, this form will contain only 1 field `email`. Sample code that you can use while making your template is here:\n\n```html\n<form method='POST' >\n {% csrf_token %}\n \n <fieldset>\n {{form}}\n </fieldset>\n \n <div style=\"margin-top: 50px;\">\n <button class=\"btn btn-outline-info\" type=\"submit\">Request New Email</button>\n </div>\n</form>\n```\nYou can apply your styles or whatever you want. (this code is used in the default template)\n\n\n**NOTE:** This info is stored in the database so you have to apply migrations (<a href='#step3'>step 3</a>) to use this feature. \n</p>\n\n<p id=\"customemailtemplate\">\n\n<h2>Custom Email Templates : </h2>\n\nThe app is packed with default HTML templates to handle the web pages but if you want to provide your own template you can do it by setting an attribute in settings.py :\n\n```\nHTML_MESSAGE_TEMPLATE = \"path/to/html_template.html\"\n\nVERIFICATION_SUCCESS_TEMPLATE = \"path/to/success.html\"\n\nVERIFICATION_FAILED_TEMPLATE = \"path/to/failed.html\"\n\nREQUEST_NEW_EMAIL_TEMPLATE = \"path/to/email.html\"\n\nLINK_EXPIRED_TEMPLATE = 'path/to/expired.html'\n\nNEW_EMAIL_SENT_TEMPLATE = 'path/to/new_email_sent.html'\n```\n```\nSUBJECT = 'subject of email'\n\n# default subject is: Email Verification Mail\n```\n</p>\n\n## Inside Templates : <hr>\n\n### Custom HTML Message Template :\n\nTwo variables are passed in context dict of \"HTML_MESSAGE_TEMPLATE\" :\n\n* ```{{request}}``` : Which is the same request passed in to send_verification_email.\n* ```{{link}}``` : Which contains verification link\n\n<b>IMPORTANT : </b> if you are using custom html message template for email that has to be sent to user, <u>provide a <b>{{link}}</b> as a template tag to contain verification link.</u> \n\n<b>You Must Pass This In Your Template</b>. Otherwise, the sent mail will not contain the verification link.\n\n\nFor Ex :\n\n```my_custom_email_message.html : ```\n\n```\n<div class=\"format-font\" >\n <a href=\"{{link}}\" class=\"my-button\" >Verify</a> # ----> The \"link\" variable is passed by the app's backend containing verification link.\n</div>\n```\n\n----> \"link\" is a variable, that contains a verification link, and is passed in an HTML message template during sending the email to the user.\n\n\n### Custom HTML Verification Success and Failed pages : \n<hr>\n\n<b>Success :</b> \n\nTwo variables are passed in the context dictionary of \"VERIFICATION_SUCCESS_TEMPLATE\" :\n\n* ```{{mgs}}```: Which contains the message to be displayed on successful verification.\n* ```{{link}}```: Which contains a redirect link to the login page.\n\n<b>In template :</b>\n\n```\n<h1 style=\"text-align: center; color: white;\">\n {{msg}} # __--> message variable\n</h1>\n\n<a href=\"{{link}}\" class=\"btn btn-primary\"> # __--> Link of login page\n Login\n</a>\n\n```\n\n<b>Failed :</b>\n\nOnly \"{{msg}}\" is passed for failed msg in the template.\n\n\n<b>In template :</b>\n\n```\n<h1 style=\"text-align: center; color: white;\">\n {{msg}}\n</h1>\n```\n\n\n\n## Successful Verification :\nAfter verification is successful, you might want to redirect the user to the login page. You can do this in two ways :\n\n* 1 <b>Redirect from success webpage.</b>\n\tThe user will be prompted to show a success page with a button on it to navigate to the Login page.\n ```\n LOGIN_URL = 'name of your login pattern'\n\n Note: This variable is also used by Django.\n ```\n* 2 <b>Redirect directly to the login page without stopping at the success message page.</b>\n\tThe user will be directly sent to the login page, bypassing the success page.\n ```\n VERIFICATION_SUCCESS_TEMPLATE = None\n ```\n</p>\n\n\n> There is always room for improvements and new ideas, feel free to raise PR or Issues\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A Django app for email verification.",
"version": "2.0.5",
"project_urls": {
"Download": "https://github.com/foo290/Django-Verify-Email/archive/refs/tags/2.0.4.tar.gz",
"Homepage": "https://github.com/foo290/Django-Verify-Email/",
"Issues": "https://github.com/foo290/Django-Verify-Email//issues",
"Repository": "https://github.com/foo290/Django-Verify-Email.git"
},
"split_keywords": [
"check",
" email",
" validation"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "46e2a9e2765d4757347dc9ced43d67d9db99d7758c4eca7beb82a09e37c86c0a",
"md5": "56ed9f105b1f3109828538dbecc8cb73",
"sha256": "59a3c941c8612ef247b5e0bbff98e9816d6902eb065c36d10cc52cc38b31a2d3"
},
"downloads": -1,
"filename": "django_email_validation-2.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "56ed9f105b1f3109828538dbecc8cb73",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 37036,
"upload_time": "2024-08-11T08:29:44",
"upload_time_iso_8601": "2024-08-11T08:29:44.997481Z",
"url": "https://files.pythonhosted.org/packages/46/e2/a9e2765d4757347dc9ced43d67d9db99d7758c4eca7beb82a09e37c86c0a/django_email_validation-2.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9fd9f1f6a9d7e38e5cdf1b3b784c457f448ed6f5f2b0b5f29ff7927fec075ab9",
"md5": "ac64e03eb7ef01151531ea8de2c80cc9",
"sha256": "ec7fb5bb0eb453df2906a5169a654ccc02e87d24e21bad4b5639a37dcde2f150"
},
"downloads": -1,
"filename": "django_email_validation-2.0.5.tar.gz",
"has_sig": false,
"md5_digest": "ac64e03eb7ef01151531ea8de2c80cc9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 32780,
"upload_time": "2024-08-11T08:29:46",
"upload_time_iso_8601": "2024-08-11T08:29:46.461611Z",
"url": "https://files.pythonhosted.org/packages/9f/d9/f1f6a9d7e38e5cdf1b3b784c457f448ed6f5f2b0b5f29ff7927fec075ab9/django_email_validation-2.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-11 08:29:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "foo290",
"github_project": "Django-Verify-Email",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "django-email-validation"
}