Created
February 23, 2011 19:33
-
-
Save niran/840999 to your computer and use it in GitHub Desktop.
Revisions
-
niran revised this gist
Feb 23, 2011 . 1 changed file with 20 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ from django.conf import settings import django.core.mail class MissingConnectionException(Exception): pass def get_connection(label=None, **kwargs): if label is None: label = getattr(settings, 'EMAIL_CONNECTION_DEFAULT', None) try: connections = getattr(settings, 'EMAIL_CONNECTIONS') options = connections[label] except KeyError, AttributeError: raise MissingConnectionException( 'Settings for connection "%s" were not found' % label) options.update(kwargs) return django.core.mail.get_connection(**options) -
niran renamed this gist
Feb 23, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
niran created this gist
Feb 23, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ EMAIL_CONNECTIONS = { 'gmail': { 'host': 'smtp.gmail.com', 'username': '[email protected]', 'password': 'password', 'port': 587, 'use_tls': True, }, 'socketlabs': { 'host': 'smtp.socketlabs-od.com', 'username': 'blah', 'password': 'password', 'use_tls': False, }, 'ses': { 'backend': 'django_ses.SESBackend', }, 'distributed': { 'backend': 'tt.mail.backends.distributed.DistributedBackend', 'components': ( # Use SES for 8% of our emails. We send about 10,000 per day, so # 8% should keep us under our initial quota of 1,000. ('ses', 0.08), ('socketlabs', 0.92), ), } } EMAIL_CONNECTION_DEFAULT = 'distributed'