Giter VIP home page Giter VIP logo

django-multimail's Introduction

Requires Django 1.3+.

The django-multimail demo site is at: http://www.django-multimail.com

multimail is a simple Django application that provides multiple-email address functionality for Django's existing User model. Features include:

  • Auto-creation of a multimail email from the email on a User object
  • Email verification via link sent to new email address
  • Auto-deletion of unverified email addresses when a user is administratively deactivated.

QUICKSTART

If you already have email sending configured, Sites configured, and are exposing messages in your templates:

  • python setup.py install
  • add multimail to installed apps
  • include 'django.template.loaders.eggs.Loader' in your TEMPLATE_LOADERS
  • In your base urls.py:
    (r'^mail/', include('multimail.urls')),
  • syncdb

DETAILED START

  • Configure your project for sending email. This usually involves setting the following properties in your settings file: EMAIL_HOST, EMAIL_HOST_USER, EMAIL_HOST_PASSWORD, EMAIL_USE_TLS, EMAIL_BACKEND. (See the Django docs: https://docs.djangoproject.com/en/1.3/topics/email/). Additionally, you will need to set either MULTIMAIL_FROM_EMAIL_ADDRESS or ADMIN_EMAIL for Multimail to use as the from mail address. ADMIN_EMAIL is used if MULTIMAIL_FROM_EMAIL_ADDRESS has not been set.

  • Be sure you are setup to use Django's sites framework (see the Django docs: https://docs.djangoproject.com/en/1.3/ref/contrib/sites/)

    multimail uses the current domain to build verification link URLs. Alternatively, you can set the MULTIMAIL_EMAIL_VERIFICATION_URL settings property. See the SETTINGS section below.

  • Be sure you are exposing messages in your templates. See Django docs on the messages framework: https://docs.djangoproject.com/en/1.3/ref/contrib/messages/

  • Be sure to include 'django.template.loaders.eggs.Loader' in the TEMPLATE_LOADERS in your settings file. You should put this after loaders that load templates you create yourself so that you can create overriding templates to replace the builtin multimail templates.

  • To install multimail, run python setup.py install

  • Add multimail to your installed apps in your settings file

  • In your base url config, add a line like the following:

    (r'^mail/', include('multimail.urls')),

  • Run syncdb

You can now start creating new EmailAddress objects for your users. A Verification email will be sent automatically when a new EmailAddress object is created.

EXAMPLE

>>> from django.contrib.auth.models import User
>>> u = User.objects.all()[0]
>>> u.save() # will automatically create an EmailAddress object for the user's current email address

You can also create EmailAddress objects for users directly: >>> from multimail.models import EmailAddress >>> addr = EmailAddress.objects.create(email='[email protected]', user=u)

SETTINGS

The following properties may be set to customize your multimail installation. Note that where default properties are enclosed with _() indicates translation via Django's ugettext. Multimail does not currently have any built-in translations for its default messages. See the Django docs for information about creating translation messages: https://docs.djangoproject.com/en/1.3/topics/i18n/localization/

MULTIMAIL_DELETE_PRIMARY
Default: False. Whether to clear the email field on the user object when the last EmailAddress is deleted.
MULTIMAIL_FROM_EMAIL_ADDRESS
Default: None, but falls back to ADMIN_EMAIL if not available
MULTIMAIL_EMAIL_ALREADY_VERIFIED_MESSAGE
Default: _("This email address has already been verified.")
MULTIMAIL_EMAIL_VERIFIED_MESSAGE **(See note below)
Default: _("Thank you for verifying your email address.")
MULTIMAIL_EMAIL_VERIFICATION_URL **(See note below)

Default: 'http://%(current_site_domain)s/mail/verify/%(emailaddress_id)s/%(verif_key)s'

Notes: if you change this URL and/or the URL configuration for calling
the Verify view, you need to be sure that you are passing the emailaddress id, and the verification key into the view call.
MULTIMAIL_INACTIVE_ACCOUNT_MESSAGE
Default: _("The account associated with this email address has been marked as inactive. Please contact the site administrator.")
MULTIMAIL_INVALID_VERIFICATION_LINK_MESSAGE
Default: _("The seleted email verification link is invalid. Please re-register your email address.")
MULTIMAIL_POST_VERIFY_URL
Default: '/'
MULTIMAIL_USE_MESSAGES
Default: True. If set to False, multimail messages using the Django messages framework will fail silently.
MULTIMAIL_VERIFICATION_EMAIL_SUBJECT **(See note below)
Default: _('Verfication required')
MULTIMAIL_VERIFICATION_EMAIL_HTML_TEMPLATE
Default: 'multimail/verification_email.html'
MULTIMAIL_VERIFICATION_EMAIL_TEXT_TEMPLATE
Default: 'multimail/verification_email.txt'

**NOTE: properties marked with ** receive a context dictionary for string templating. The default values do not take advantage of this, preferring static strings in order to take advantage of translation capabilities. The following keys are passed to these strings: current_site_domain

current_site_id current_site_name emailaddress_id email (the email on the current multimail email object) first_name last_name primary_email (the email on the user object) user_id username verif_key verify_link

Note that MULTIMAIL_EMAIL_VERIFICATION_URL does not get the verif_link key for obvious reasons.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.