djangosnippets.org: Latest snippets tagged with 'mail'https://djangosnippets.org/tags/mail/2015-04-13T20:40:28.002317-05:00Simple class to organize email templates
2015-04-13T20:40:28.002317-05:00jeanhttps://djangosnippets.org/snippets/10479/<p><strong>Provides pattern to organize and send your email messages.</strong></p>
Freely redistributableOne line SMTP sink server
2014-07-25T19:19:20.221144-05:00Baguagehttps://djangosnippets.org/snippets/3085/<p>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.</p>
Freely redistributableMultiple emails field
2014-05-06T09:14:36.037016-05:00cuchachttps://djangosnippets.org/snippets/3047/<p>Model Field allowing to store multiple emails in one textual field. Emails separated by comma. All emails are validated. Works with Django admin.</p>
Freely redistributableOther translation block
2011-05-02T03:41:25.283256-05:00cecedille1https://djangosnippets.org/snippets/2423/<p>Use in a with statement to set the translation to another locale for a block<br />
>>> from django.utils.translation import ugettext
>>> ugettext('title')
u'title'
>>> with Translation('fr') as locale:
...: print locale.locale
...: print ugettext('title')
...: <br />
...: <br />
fr
titre
>>> ugettext('title')
u'title'</p>
Freely redistributableBetter debugging mail server
2011-02-21T09:38:53.470202-06:00yourcelfhttps://djangosnippets.org/snippets/2367/<p>Python includes (and <a href="http://docs.djangoproject.com/en/dev/topics/email/?from=olddocs#testing-e-mail-sending">Django recommends</a>) a simple email debugging server which prints mail to stdout. The trouble is, unlike any half-competent mail reader, long lines are broken up, and thus long URLs don't work without modification.</p>
<p>This snippet simply unwraps long lines (broken by "=") so long URLs can …</p>
Freely redistributableReportBug() with tons of debug in mail
2010-10-01T08:55:50.330162-05:00sleepycalhttps://djangosnippets.org/snippets/2214/<p>This basically takes the debug you get from setting debug=True, but instead, pipes it into an email and sends it over to you.
</p>
<p>I have extracted this out of our de framework, it should work, but some modifications may be necessary.
</p>
Freely redistributableReportBug() (exception emails - ala django debug style)
2010-09-12T09:45:48.935050-05:00sleepycalhttps://djangosnippets.org/snippets/2191/<p>ReportBug() allows you to send exception details to you, via email, but with
far more detail than the default. It uses the base function for the traceback
used by the Debug mode on Django.
</p>
<p>This is a first revision, so the emails have no decent styling, but it works,
and …</p>
Freely redistributableEmail queue in DB
2010-04-19T02:33:21.560657-05:00fish2000https://djangosnippets.org/snippets/1993/<p>This is what I use to send simple status emails from my sites. Instead of a django.core.mail.send_mail call, which can take an irrritatingly, nondeterministically long time to return (regardless of error state), you can stow the emails in the database and rely on a separate interpreter process send them off …</p>
Freely redistributablesend_mail wrapper with DEBUG email trapping
2010-02-20T12:45:24.768634-06:00udfalksohttps://djangosnippets.org/snippets/1932/<p>By using this simple wrapper instead of Django's default send_mail function, you gain the peace of mind of knowing that when settings.DEBUG == True, all the emails will be sent to you instead of the original recipient. Handy for testing.<br />
</p>
Freely redistributableMore informative error mailings
2008-03-07T22:16:53.986771-06:00kcarnoldhttps://djangosnippets.org/snippets/631/<p>This middleware makes the admin error emails a lot more informative: you get the same HTML response that you get with <code>DEBUG=True</code>.</p>
<p>It uses the base class defined in <a href="http://www.djangosnippets.org/snippets/638/">#638</a>.</p>
<p>You will probably want to apply the patch for <a href="http://code.djangoproject.com/ticket/6748">#6748</a> to help avoid slowdowns caused by unintentional database …</p>
Freely redistributableFixedEmailMessage
2008-03-06T05:01:03.695132-06:00buriyhttps://djangosnippets.org/snippets/630/<p>Django EmailMessage class has no cc support and has bug in bcc support.</p>
<p>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 …</p>
Freely redistributableSend information mails to related staff members.
2007-06-15T01:57:59.837786-05:00sleytrhttps://djangosnippets.org/snippets/287/<p>You can use this method to send information mails to the related staff members about section specific site activity. All users which explicitly permitted to 'change' given object will be informed about activity.</p>
<p>If you defined get_absolute_url in your model then you can simply use it like this;</p>
<p>`
obj=form.save() …</p>
Freely redistributableSending html emails with images using Django templates
2007-06-14T10:04:15.962204-05:00sleytrhttps://djangosnippets.org/snippets/285/<p>I have not extensively test this yet. But working for templates with embedded images.</p>
<p>If you want to use Django template system use <code>msg</code> and optionally <code>textmsg</code> as template context (dict) and define <code>template</code> and optionally <code>texttemplate</code> variables.
Otherwise msg and textmsg variables are used as html and text message …</p>
Freely redistributable