entity encoded string for a somewhat safer email-address.
this filter encodes strings to numeric entities, almost every standard-browsers decodes the entities and display them the right way.
needless to say that bots are smart, so this is not a 100% guaranteed spam prevention.
http://steven.bitsetters.com/articles/2009/03/09/testing-email-registration-flows-in-django/
Testing email registration flows is typically a pain. Most of the time I just want to sign up with a test user, get the email link and finish the flow. I also want to be able to automate the whole process without having to write some SMTP code to check some mail box for the email.
The best way I’ve found to do this is just to write out your emails to some file instead of actually sending them via SMTP when your testing. Below is some code to do just that. I’ve also created a Django management script that will open the last email sent out from your application, find the first link in it and open it in your web browser. Quite handy for following email registration links without logging into your email and clicking on them manually.
Example Usage in the template:
<p>{{ email|hide_email }}<br />
{{ email|hide_email:"Contact Me" }}<br />
{% hide_email "[email protected]" %}<br />
{% hide_email "[email protected]" "John Smith" %}</p>
{{ text_block|hide_all_emails|safe }}
All hidden emails are rendered as a hyperlink that is protected by
javascript and an email and name that are encoded randomly using a
hex digit or a decimal digit for each character.
Example of how a protected email is rendered:
<noscript>(Javascript must be enabled to see this e-mail address)</noscript>
<script type="text/javascript">// <![CDATA[
document.write('<a href="mai'+'lto:john@example.com">John Smith</a>')
// ]]></script>
Template filter to hide an email address away from any sort of email harvester type web scrapers and so keep away from spam etc.
The filter should be applied on a string which represents an email address. You can optionally give the filter a parameter which will represent the name of the resulting email href link. If no extra parameter is given the email address will be used as the href text.
{{ email|mungify:"contact me" }}
or
{{ email|mungify }}
The output is javascript which will write out the email href link in a way so as to not actually show the email address in the source code as plain text.
Also posted on [my site](http://www.tomcoote.co.uk/DjangoEmailMunger.aspx).
This is a simplified rip-off of django-registration and the built-in forms and views in contrib.auth. It requires no models and is very customizable. Saving the form creates a user with an unusable password and sends a password reset email (by default, uses the password reset template too).
You must create templates/registration_form.html and the view registration_complete. I ripped this out of my site, which has a more complicated form, so I may be missing a few other things here.
This very basic function I was missing in this part of the Django Documentation when creating a custom MultiEmailField:
http://docs.djangoproject.com/en/dev/ref/forms/validation/
I needed a quick way to send e-mails to other people involved in a project when I committed code - so that designers would know that templatetag *x* was available (or fixed), etc - and am really fond of how [unfuddle](http://unfuddle.com/) handles their subversion notifications. This isn't nearly as polished as theirs, but I figured it was a good place to start.
Hope someone else finds this as handy as I have.
Django documentation is lacking in giving an example for sending an email with attachment. Hopefully this code helps those who are trying to send email with attachments
A simple backend which allows you to login with either an email address or a username.
It should be combined with another backend for checking permissions:
AUTHENTICATION_BACKENDS = (
'myproject.accounts.backends.EmailOrUsernameModelBackend',
'django.contrib.auth.backends.ModelBackend'
)
Activate this middleware and define `LOG_FORMAT` & `LOG_ROOTS` in your `settings.py`. Then you can use Python's `logging` module for easy logging within your application.
This templatetag obsfucate mailto link and hide it while not happen onmouseover event.
Usage:
{% hide_email object.author object.author.email %}
Output:
<a href="mailto:[email protected]"
onmouseover="var a=String.fromCharCode(79+35,14+103,66+41,30+71,49+49,16+81);
var b=String.fromCharCode(14+50,9+105,61+56,81+26,92+9,2+96,20+77,13+33,75+24,32+79,31+78);
this.href=['mail','to:',a,b].join('');">rukeba</a>
Based on [Email Obsfucator](http://www.djangosnippets.org/snippets/536/) and [forums at Yandex.Market](http://market.yandex.ru/forums/).
Example at [my guitar blog](http://rukeba.com/ra/2008/01/15/oasis-wonderwall/)
Sometimes when sending email you want to specify a Return-Path different from the "From:" address on the email. The Return-Path is used for bounced email and is required for [VERP](http://en.wikipedia.org/wiki/VERP).
This class overrides SMTPConnection so that you can specify return_path.
A quickie clone of good old fashion [Formmail.pl](http://www.scriptarchive.com/formmail.html) any form that is a subclass of FormMail will have its conents emailed to all staff members on the site.