Tuesday, March 29, 2016

Re: EMAIL_BACKEND doesn't works with Amazon SES!?

Thanks guys, 587 worked

Em segunda-feira, 28 de março de 2016 21:56:12 UTC-3, Neto escreveu:
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:

raise 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/8f5643f4-043a-4233-a0c3-2ca9c05a3a33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment