Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Configuration(models.Model):
- email_use_tls = models.BooleanField(_(u'EMAIL_USE_TLS'),default=True)
- email_host = models.CharField(_(u'EMAIL_HOST'),max_length=1024)
- email_host_user = models.CharField(_(u'EMAIL_HOST_USER'),max_length=255)
- email_host_password = models.CharField(_(u'EMAIL_HOST_PASSWORD'),max_length=255)
- email_port = models.PositiveSmallIntegerField(_(u'EMAIL_PORT'),default=587)
- ....
- from django.core.mail import EmailMessage
- from django.core.mail.backends.smtp import EmailBackend
- config = Configuration.objects.get(**lookup_kwargs)
- backend = EmailBackend(host=config.host, port=congig.port, username=config.username,
- password=config.password, use_tls=config.use_tls, fail_silently=config.fail_silently)
- email = EmailMessage(subject='subj', body='body', from_email=from_email, to=to,
- connection=backend)
- email.send()
- backend = EmailBackend(host=config.host, port=congig.port, username=config.username,
- password=config.password, use_tls=config.use_tls, fail_silently=config.fail_silently)
- email = EmailMessage(subject='subj', body='body', from_email=from_email, to=to,
- connection=backend)
- $ pip install django-des
- INSTALLED_APPS = (
- ...
- 'django_des',
- ...
- )
- EMAIL_BACKEND = 'django_des.backends.ConfiguredEmailBackend'
- from django_des import urls as django_des_urls
- urlpatterns = [
- ...
- url(r'^django-des/', include(django_des_urls)),
- ]
Add Comment
Please, Sign In to add comment