Login

Tag "email"

Snippet List

FixedEmailMessage

Django EmailMessage class has no cc support and has bug in bcc support. Core developers won't add cc support (see ticket http://code.djangoproject.com/ticket/5790), and I don't want to wait half a year until they will realize they have a flaw that bcc recipients are sent to regular "to:" recipients and fix it. So, if you want to use EmailMessage class right now, you'd better use FixedEmailMessage class. Class contract is the same, except for a new cc constructor argument.

  • email
  • smtp
  • mail
  • message
  • emailmessage
  • cc
Read More

Email on new comments

In response to [#366](/snippets/366/), this is a subclass of the `CommentModerator` class from `comment_utils` which does nothing except email the "owner" of an object whenever a new comment is posted on it; all other moderation options remain inactive.

  • email
  • comments
Read More

Email on new comments

I know ubernostrum has the nice comment_utils, but I need something that would notify the owner of the comment's content object (where the model has a foreignkey field to django.contrib.auth.models.User), but I didn't need all the moderation stuff. I stuck this in my models.py, where YOURMODEL is the name of the model object with comments attached, and a user field.

  • email
  • comments
Read More

Sending html emails with images using Django templates

I have not extensively test this yet. But working for templates with embedded images. If you want to use Django template system use `msg` and optionally `textmsg` as template context (dict) and define `template` and optionally `texttemplate` variables. Otherwise msg and textmsg variables are used as html and text message sources. If you want to use images in html message, define physical paths and ids in tuples. (image paths are relative to MEDIA_ROOT) example: images=(('email_images/logo.gif','img1'),('email_images/footer.gif','img2')) use them in html like this: `<img src="cid:img1"><br><img src="cid:img2">` stripogram and feedparser modules are used for extract plain text from html message source. If you are going to define text partition explicitly, than you can comment out line 10,11 and 48.

  • template
  • email
  • mail
  • html
Read More

E-mail quoting filters and tags

Ttemplates and filters for quoting e-mails in templates. The `quoted_email` tag takes a template, renders it and quotes the result. The `quote_text` filter puts one or more levels of quotes around the passed text.

  • filter
  • tag
  • filters
  • email
  • tags
  • quoting
Read More

email_links

A very basic app centered around a template tag that takes an e-mail address and optional label and returns a link to an e-mail form. This way, you can easily throw e-mail addresses into your template that will automatically link to an e-mail form instead of displaying the e-mail address itself. The model for this app is extremely simple, with only one field to store the e-mail address. When an e-mail is passed to the email_link template tag, the e-mail address is added to the database if it is not already there. This is stored in the database in order to keep the full e-mail address hidden from the viewer. To use, simply create an app called 'email_links' (or you can change the name if you also change line 4 of email_extras.py to reflect the change). Then use the models.py and views.py provided. Add a templatetags directory under your app, and add email_extras.py and a blank __init__.py In your urls.py, add the following to your urlpatterns (subsitute project_name for your own): `(r'^email/(?P<email_id>[0-9]+)/$', 'project_name.email_links.views.email_form'),` Create two templates: email_links/email_form.html and email_links/thanks.html (the examples here are extremely basic - make them however you want). Finally, in a template where you want to provide a link to e-mail someone, first load email_extras: `{% load email_extras %}` Then do one of the following: `{% email_link "[email protected]" %}` `{% email_link "[email protected]" "E-mail someone" %}` Both will create a link to the e-mail form. The first will use mask_email (from the snippet by jkocherhans) to create the link. The second will display the second argument "E-mail someone" in the link. Also note that I've used the Sites add-on to generate the links, but you can easily change this to suit your needs. I hope all of this makes sense. I'm a bit tired, but wanted to get this up before bed.

  • filter
  • tag
  • email
Read More

encode_mailto

This is a django filter which will create an html mailto link when you use the syntax: {{ "[email protected]"|encode_mailto:"Name" }} Results in: <a href="mailto:[email protected]">Name</a> Except everything is encoded as html digits. The encoding is a string of html hex and decimal entities generated randomly. If you simply want a string encoding use: {{ "name"|encode_string }} This was inspired by John Gruber's [Markdown](http://daringfireball.net/projects/markdown/syntax#autolink) project

  • filter
  • email
  • encode
Read More

New forms signup validation

This snippets provide username availability, double email and password validation. You can use it this way : f = SignupForm(request.POST) f.is_valid()

  • newforms
  • email
  • clean
  • signup
  • password
Read More

Import mail into a Django model

A mildly crufty script to slurp mail from an mbox into a Django model. I use a variant of this script to pull the contents of my scammy-spam mbox into the database displayed at <http://purportal.com/spam/>

  • email
  • faceless
  • utility
Read More
Author: pbx
  • 4
  • 11

Authenticate with Email Address

This code gives you the ability to authenticate a user by their email address instead of the username. I've also added the ability to authenticate via LDAP. Some code used from this [snippet](http://www.djangosnippets.org/snippets/74/)

  • admin
  • user
  • email
  • authenticate
  • ldap
Read More

Django Registration with GMail account

This code works with Django-registration app found here: http://code.google.com/p/django-registration/ If you plan to use this django-registrtion code in your website to allow user registration but do not run your own email server,this snippet can be handy. It uses gmail server to send out email. You have to install libgmail module first. Add two lines to your `settings.py` GMAIL_USERNAME = '[email protected]' GMAIL_PASSWORD = 'your_password' Change models.py - create_inactive_user(...) as given above

  • registration
  • email
  • gmail
  • django-registration
Read More

SMTP sink server

In development, we need a SMTP Server to see the results of send mail via SMTP protocol in Python application. Instead of configure a mail daemon, we could use this little script to receive the SMTP request, and save each session into an EML file. *.eml could be viewed with your favorite email client, you need not send them out. [EML description](http://filext.com/detaillist.php?extdetail=EML) **Update**: Fix bug for overwrite files when received multi-message in one SMTP session.

  • email
  • debug
  • smtp
  • server
  • eml
Read More

mask_email filter

Mask an email address by removing most of the first portion and replacing it with "..." For example. If you have a variable in your template context named `email_address `, and its value is "[email protected]" {{ email_address|mask_email }} will render as: [email protected] If the part preceding @domain.com is shorter than 5 characters, only the first letter will be used, followed by "...". So if we have "[email protected]" {{ email_address|mask_email }} will render as: [email protected]

  • filters
  • email
Read More

Using Templates to Send E-Mails

This is a basic example for sending an email to a user (in this case, when they've signed up at a website) using the Django template framework. It's really quite simple - we're just using a plain text template instead of HTML, and using the output of the template's 'render()' method as the message body. Of course, in your project you won't blindly use data from request.POST! This example was first posted on [my blog at rossp.org](http://www.rossp.org/blog/2006/jul/11/sending-e-mails-templates/)

  • templates
  • email
Read More

74 snippets posted so far.