Multiple e-mail backends for Django Framework
Written for Django 1.7 and Python 3
In settings.py:
Add 'django_multi_mailer'
into INSTALLED_APPS
Set the EMAIL_BACKEND variable to EMAIL_BACKEND = 'django_multi_mailer.backends.MultiEmailBackend'
Set the EMAIL_MULTI variable to
EMAIL_MULTI = [
{
'HOST': 'put_your_host_here.com',
'PORT': 25,
'USE_SSL': False,
'USE_TLS': True,
'TIMEOUT': 120,
'FAIL_SILENTLY': False,
'CREDENTIALS': [
('[email protected]', 'password'),
('[email protected]', 'password'),
('[email protected]', 'password'),
('[email protected]', 'password'),
('[email protected]', 'password')
]
},
{
'HOST': 'second_host.com',
'PORT': 25,
'USE_SSL': False,
'USE_TLS': True,
'TIMEOUT': 120,
'FAIL_SILENTLY': False,
'CREDENTIALS': [
('first@second_host.com', 'password'),
]
},
]
That's all, you can now send e-mails using default django send_mail function
from django.core.mail import send_mail
subject = 'Email Topic'
content = 'Email Content'
recipient_list = ['[email protected]']
send_mail(subject, content, None, recipient_list)