Login

Tag "email"

Snippet List

Email authentication backend

Fixed minimal version, works with Django 1.7+, tested on Django 1.9. Add the following to your settings: AUTHENTICATION_BACKENDS = [ 'project.backends.UserModelEmailBackend', # Login w/ email 'django.contrib.auth.backends.ModelBackend', # Login w/ username ]

  • authentication
  • email
  • auth
  • username
  • backend
Read More

Template Tag to protect the E-mail address

Update to https://djangosnippets.org/snippets/1907/ to be a bit more flexible, and code cleaned up a tiny bit. To use, add this snippet as a file in a templatetags folder in an app or in a project. Then include and call the tag with {% obfuscate_email 'email' %} or {% obfuscate_email 'email' 'link_text' %} if 'link_text' is provided, it will be used as the text in the body of the <a> tag. If not, then the email will be used.

  • email
  • spam
  • obfuscate
Read More

Custom Auth Backend to use E-Mail in Django

Instead of the default Django User the Auth Model is 'customer' from the usercp App. User's can use username as a display to the public, without disclosing their login information. This way they can use a forum with their username, which is seen by everyone. The login credentials, however are more privat, since it is the e-mail address. Allowing the user to not disclose any information.

  • django
  • authentication
  • email
Read More

One line SMTP sink server

Start simple SMTP server on localhost:25 and print to standard output all email headers and the email body. Useful for debugging outgoing mail without configuring SMTP daemon in development enviroment.

  • email
  • debug
  • smtp
  • mail
  • debugging
  • debuggingserver
Read More

Multiple emails field

Model Field allowing to store multiple emails in one textual field. Emails separated by comma. All emails are validated. Works with Django admin.

  • multiple
  • email
  • validation
  • mail
  • multifield
Read More

Email Auth

Yet another authentication by email address. This one is quick and dirty as we are saving email address in both Username and Email fields. For proper way how to deal with it see https://docs.djangoproject.com/en/1.6/topics/auth/customizing/#auth-custom-user

  • email
  • auth
Read More

Display values from a bound (submitted) form

Function that takes a bound form (submitted form) and returns a list of pairs of field label and user chosen value. It takes care of: 1. fields that are not filled out 2. if you want to exclude some fields from the final list 3. ChoiceField (select or radio button) 4. MultipleChoiceField (multi-select or checkboxes) Usage: if form.is_valid(): form_data = get_form_display_data(form, exclude=['captcha']) It's trivial to display the list of pairs in a template: {% for key, value in form_data %} {{ key }}: {{ value }}{% endfor %}

  • template
  • email
  • form
Read More

Multiple emails form field

Validate form field that include email or emails separated by 'token' kwargs, by default ',' a comma. Return a list [] of email(s). Check validity of the email(s) from django EmailField regex (tested with 1.3, but normally will also work with 1.5)

  • multiple
  • email
  • validation
  • form
  • field
  • list
Read More

Decorator to execute a method only once

Beware if using Amazon Simple Queue Service to execute Celery tasks which send email messages! Sometimes SQS messages are duplicated which results in multiple copies of the messages being sent. This is a simple decorator which uses a cache backend to prevent the task from executing twice in a specified period. For example: @task @execute_once_in(3600*24*7) def cron_first_week_follow_up(): """ Send a follow-up email to new users! """ pass For more info see <http://atodorov.org/blog/2013/12/06/duplicate-amazon-sqs-messages-cause-multiple-emails/> <http://atodorov.org/blog/2013/12/11/idempotent-django-email-sender-with-amazon-sqs-and-memcache/>

  • django
  • email
  • decorator
  • amazon
  • queue
  • celery
Read More

Email backend to BCC all emails

The backend lets you quickly get an idea of all emails that are sent out. Helpful for debugging or keeping an archive of all communications. Use instead of Django's SMTPBackend.

  • email
  • backend
  • bcc
Read More

Get email and push on couchdb - Model

view/admin.py ` def reactor(request): context = { 'email': read_mailbox() } return render_to_response(_lookup_template('dashboard'), context, context_instance=RequestContext(request)) ` **_Design all.js** ` function (doc) { if (doc.doc_type == 'MailArchive') { emit(doc._id, doc); } } ` **reduce.js** `_count`

  • email
  • couchdb
  • couchdbkit
Read More

74 snippets posted so far.