I'm trying to send emails with Amazon SES, but when I use default EMAIL_BACKEND raise error:
-- Config:
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' # this is default
EMAIL_HOST = 'email-smtp...amazonaws.com'
EMAIL_PORT = 465
EMAIL_HOST_USER = '...'
EMAIL_HOST_PASSWORD = '...'
EMAIL_USE_TLS = True
Error:
from https://github.com/bancek/django-smtp-ssl, works right.
What the problem with default EMAIL_BACKEND? Why I can't use him?
raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
smtplib.SMTPServerDisconnected: Connection unexpectedly closed
If I use:
EMAIL_BACKEND = 'django_smtp_ssl.SSLEmailBackend'
from https://github.com/bancek/django-smtp-ssl, works right.
Code of this backend:
import smtplib
from django.core.mail.utils import DNS_NAME
from django.core.mail.backends.smtp import EmailBackend
class SSLEmailBackend(EmailBackend):
def open(self):
if self.connection:
return False
try:
self.connection = smtplib.SMTP_SSL(self.host, self.port, local_hostname=DNS_NAME.get_fqdn())
if self.username and self.password:
self.connection.login(self.username, self.password)
return True
except:
if not self.fail_silently:
raise
What the problem with default EMAIL_BACKEND? Why I can't use him?
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d71c947b-db14-4373-b412-41e5dc5a7cff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment