All Projects → vinta → Django Email Confirm La

vinta / Django Email Confirm La

Licence: mit
Django email confirmation for any model and any field

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Django Email Confirm La

Modoboa
Mail hosting made simple
Stars: ✭ 1,998 (+8586.96%)
Mutual labels:  django, email
Django Anymail
Django email backends and webhooks for Amazon SES, Mailgun, Mailjet, Postmark, SendGrid, Sendinblue, SparkPost and more
Stars: ✭ 1,109 (+4721.74%)
Mutual labels:  django, email
Hawkpost
Generate links that users can use to submit messages encrypted with your public key.
Stars: ✭ 843 (+3565.22%)
Mutual labels:  django, email
Python Sparkpost
SparkPost client library for Python
Stars: ✭ 87 (+278.26%)
Mutual labels:  django, email
Django mail admin
The one and only django app to receive & send mail with templates and multiple configurations.
Stars: ✭ 140 (+508.7%)
Mutual labels:  django, email
Django Notifs
Modular Notifications (InApp, Email, SMS, CustomBackend etc) for Django
Stars: ✭ 105 (+356.52%)
Mutual labels:  django, email
Django Amazon Ses
A Django email backend that uses Boto3 to interact with Amazon Simple Email Service (SES).
Stars: ✭ 77 (+234.78%)
Mutual labels:  django, email
Django Mail Templated
Send emails using Django template system
Stars: ✭ 146 (+534.78%)
Mutual labels:  django, email
Django Herald
A Django messaging library
Stars: ✭ 159 (+591.3%)
Mutual labels:  django, email
Django2.0 Course
Django2.0视频教程相关代码(杨仕航)
Stars: ✭ 897 (+3800%)
Mutual labels:  django
React email editor
This project is experimental! It's my attempt to create visual email template editor using React+Redux+etc... tools stack.
Stars: ✭ 19 (-17.39%)
Mutual labels:  email
Django Ninja
💨 Fast, Async-ready, Openapi, type hints based framework for building APIs
Stars: ✭ 875 (+3704.35%)
Mutual labels:  django
Postmark Java
Official Java client library for the Postmark HTTP API
Stars: ✭ 18 (-21.74%)
Mutual labels:  email
Email
Faster MIME Mail Parser
Stars: ✭ 19 (-17.39%)
Mutual labels:  email
Strawberry
A new GraphQL library for Python 🍓
Stars: ✭ 891 (+3773.91%)
Mutual labels:  django
Python sec
python安全和代码审计相关资料收集 resource collection of python security and code review
Stars: ✭ 921 (+3904.35%)
Mutual labels:  django
Django rest example
Django/DRF rest application example.
Stars: ✭ 17 (-26.09%)
Mutual labels:  django
Campus42
Website that allows 42 Silicon Valley students to find each other on the map
Stars: ✭ 17 (-26.09%)
Mutual labels:  django
Django Bookworm
A fun project to store my learning from each book that I read.
Stars: ✭ 23 (+0%)
Mutual labels:  django
Django Uwsgi Taskmanager
Django application to monitor and manage long and/or recurring tasks through uWSGI.
Stars: ✭ 22 (-4.35%)
Mutual labels:  django

django-email-confirm-la

.. image:: http://img.shields.io/travis/vinta/django-email-confirm-la/master.svg?style=flat-square :target: https://travis-ci.org/vinta/django-email-confirm-la

.. image:: https://img.shields.io/coveralls/vinta/django-email-confirm-la/master.svg?style=flat-square :target: https://coveralls.io/github/vinta/django-email-confirm-la

.. image:: http://img.shields.io/pypi/v/django-email-confirm-la.svg?style=flat-square :target: https://pypi.python.org/pypi/django-email-confirm-la

Django email confirmation for any Model and any Field.

Requirements

  • Python (3.5, 3.6, 3.7, 3.8)
  • Django (2.0, 2.1, 2.2, 3.0, 3.1)

Installation

.. code-block:: bash

$ pip install django-email-confirm-la

In your settings.py:

Add the email_confirm_la app (put it after your apps) and set the required settings:

.. code-block:: python

INSTALLED_APPS = (
    ...
    'your_app',
    'email_confirm_la',
    ...
)

EMAIL_CONFIRM_LA_HTTP_PROTOCOL = 'https'
EMAIL_CONFIRM_LA_DOMAIN = 'vinta.ws'
EMAIL_CONFIRM_LA_AUTOLOGIN = True
EMAIL_CONFIRM_LA_TEMPLATE_CONTEXT = {
    'THE_ANSWER': 42,
}

If you are using the sites <https://docs.djangoproject.com/en/dev/ref/contrib/sites/>_ framework, then EMAIL_CONFIRM_LA_DOMAIN can be omitted and Site.objects.get_current().domain will be used.

In your urls.py:

.. code-block:: python

urlpatterns = [
    ...
    url(r'^email_confirmation/', include('email_confirm_la.urls', namespace='email_confirm_la')),
    ...
]

then run

.. code-block:: bash

$ python manage.py migrate

Models

For User Model

.. code-block:: python

from django.contrib.auth.models import User
from email_confirm_la.models import EmailConfirmation

user = User.objects.get(username='vinta')
email = '[email protected]'
EmailConfirmation.objects.verify_email_for_object(email, user)

For Any Model And Any Field

Assumed you have a model:

.. code-block:: python

from django.db import models
from django.contrib.contenttypes.fields import GenericRelation  # Django 1.7+
from django.contrib.contenttypes.generic import GenericRelation

class YourModel(models.Model):
    ...
    customer_support_email = models.EmailField(max_length=255, null=True, blank=True)
    marketing_email = models.EmailField(max_length=255, null=True, blank=True)
    ...

    # optional, but recommended when you want to perform cascade-deletions
    email_confirmations = GenericRelation('email_confirm_la.EmailConfirmation', content_type_field='content_type', object_id_field='object_id')

And you want to verify some emails:

.. code-block:: python

from your_app.models import YourModel
from email_confirm_la.models import EmailConfirmation

some_model_instance = YourModel.objects.get(id=42)

EmailConfirmation.objects.verify_email_for_object(
    email='[email protected]',
    content_object=some_model_instance,
    email_field_name='customer_support_email'
)

EmailConfirmation.objects.verify_email_for_object(
    email='[email protected]',
    content_object=some_model_instance,
    email_field_name='marketing_email'
)

Signals

  • post_email_confirmation_send
  • post_email_confirmation_confirm

In your models.py:

.. code-block:: python

from django.dispatch import receiver
from email_confirm_la.signals import post_email_confirmation_confirm

@receiver(post_email_confirmation_confirm)
def post_email_confirmation_confirm_callback(sender, confirmation, **kwargs):
    model_instace = confirmation.content_object
    email = confirmation.email
    old_email = kwargs['old_email']

    do_your_stuff()

Commands

.. code-block:: bash

$ python manage.py clear_expired_email_confirmations

Templates

You will want to override the project's email message and confirmation pages.

Ensure the email_confirm_la app in INSTALLED_APPS is after the app that you will place the customized templates in so that the django.template.loaders.app_directories.Loader <https://docs.djangoproject.com/en/dev/ref/templates/api/#django.template.loaders.app_directories.Loader>_ finds your templates first.

There are following template that you can override:

  • email_confirm_la/email/email_confirmation_subject.txt: Produces the subject line of the email.
  • email_confirm_la/email/email_confirmation_message.html: The HTML body of the email.
  • email_confirm_la/email_confirmation_success.html: What the user sees after clicking a confirmation link (on success).
  • email_confirm_la/email_confirmation_fail.html: What the user sees after clicking a invalid confirmation link.
  • email_confirm_la/email_confirmation_expiration.html: What the user sees after clicking an expired confirmation link.

Settings

Default values of app settings:

.. code-block:: python

EMAIL_CONFIRM_LA_HTTP_PROTOCOL = 'http'
EMAIL_CONFIRM_LA_DOMAIN = 'example.com'
EMAIL_CONFIRM_LA_CONFIRM_EXPIRE_SEC = 60 * 60 * 24 * 1  # 1 day
EMAIL_CONFIRM_LA_CONFIRM_URL_REVERSE_NAME = 'email_confirm_la:confirm_email'
EMAIL_CONFIRM_LA_TEMPLATE_CONTEXT = {}
EMAIL_CONFIRM_LA_AUTOLOGIN = False

Run Tests

.. code-block:: bash

$ pip install -r requirements_test.txt
$ python setup.py test

# or

$ docker build -t email_confirm_la .
$ docker run --rm=true -v `pwd`:/app email_confirm_la
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].