django-firstclass

A proxy email backend for Django that allows for global email transformations
Download

django-firstclass Ranking & Summary

Advertisement

  • Rating:
  • License:
  • MIT/X Consortium Lic...
  • Price:
  • FREE
  • Publisher Name:
  • Andrew McCloud
  • Publisher web site:
  • http://amccloud.com

django-firstclass Tags


django-firstclass Description

django-firstclass is a proxy email backend for Django that allows for global email transformations such as automatically creating a plain text version of html emails or automatically creating an online version of the email that can be read in browser.Installpip install django-firstclass- Add 'firstclass' to INSTALLED_APPS- Add url(r'^email/', include('firstclass.urls')) to your urlconf.- Set EMAIL_BACKEND to 'firstclass.backends.ProxyBackend'- SyncdbSettingsFIRSTCLASS_EMAIL_BACKENDThe email backend to send processed emails to after they've gone through the middleware.DefaultFIRSTCLASS_EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'FIRSTCLASS_MIDDLEWAREFirstclass middleware works just like Django middleware. Firstclass applies middleware in the order it's defined in FIRSTCLASS_MIDDLEWARE, top-down. You can even create your own middleware. See: Custom MiddlewareDefaultFIRSTCLASS_MIDDLEWARE = ( 'firstclass.middleware.online.ViewOnlineMiddleware', 'firstclass.middleware.alternative.MultiAlternativesMiddleware', 'firstclass.middleware.text.PlainTextMiddleware',)Available MiddlewarePlainTextMiddlewarefirstclass.middleware.text.PlainTextMiddlewareSettingsFIRSTCLASS_PLAINTEXT_RULESA dictionary of rules for converting html to plain text. Keys should be a qualified selector for BeautifulSoup's findAll. Values can either be a formatting string or a function that accepts one argument, attrs. All attributes found on the element can be used for formatting or will be passed to your function in attrs.DefaultFIRSTCLASS_PLAINTEXT_RULES = { 'a': '(%(text)s) %(href)s', 'img': '%(title)s: %(src)s',}MultiAlternativesMiddlewarefirstclass.middleware.alternative.MultiAlternativesMiddlewareCoerces email to EmailMultiAlternatives so that a multiple versions of the email can be added.ViewOnlineMiddlewarefirstclass.middleware.online.ViewOnlineMiddlewareSaves all emails and adds a link to the email body so that they can be viewed online in a web browser. Ideally this middleware should come before the PlainTextMiddlewware so that the link that is added is converted to plain text.ViewOnlineMiddleware uses the template firstclass/view_online_wrap.html to append the link to the bottom of the email. You can override this by providing your own in your templates directory.SettingsFIRSTCLASS_VIEWONLINE_AUTHIf this is True the user will need to be logged in to view email. The user's email would also need to be one of the original recipients of the email.DefaultFIRSTCLASS_VIEWONLINE_AUTH = FalseCustom MiddlewareDefining custom middleware for Firstclass is simple. Middleware should be a single Python class that defines process_message.process_messageprocess_message(self, message)message is an EmailMessage or an EmailMessage like object. process_message should return message or None. If it returns None the email will be dropped.Viewsview_message_onlinefirstclass.views.view_message_online(request, key, template='firstclass/message.html')This view is used by the ViewOnlineMiddleware middleware. It's template is located at firstclass/message.html. You can override this by providing your own in your templates directory. The render context contains message which is Message model instance.Product's homepage


django-firstclass Related Software