Django Sending Email : SMTPServerDisconnected: Connection unexpectedly closed
Question: hello i want to sending email activation use django registration redux.

this is my setting.py

    
    
    EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
    
    ACCOUNT_ACTIVATION_DAYS = 3
    EMAIL_HOST = 'smtp.gmail.com'
    EMAIL_HOST_USER = 'blahblah@gmail.com'
    EMAIL_HOST_PASSWORD = 'blahpassword'
    EMAIL_PORT = 465
    EMAIL_USE_SSL = True
    
    LOGIN_REDIRECT_URL = '/'
    

when i try with

> python manage.py shell
>
> from django.core.mail import send_mail
>
> send_mail('Test', 'This is a test', 'youremail@gmail.com',
> ['toemail@gmail.com'])

i am getting error like this:

    
    
        Traceback (most recent call last):
      File "<console>", line 1, in <module>
      File "/home/apsijogja/djangogirls/myvenv/local/lib/python2.7/site-packages/django/core/mail/__init__.py", line 62, in send_mail
        return mail.send()
      File "/home/apsijogja/djangogirls/myvenv/local/lib/python2.7/site-packages/django/core/mail/message.py", line 286, in send
        return self.get_connection(fail_silently).send_messages([self])
      File "/home/apsijogja/djangogirls/myvenv/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 92, in send_messages
        new_conn_created = self.open()
      File "/home/apsijogja/djangogirls/myvenv/local/lib/python2.7/site-packages/django/core/mail/backends/smtp.py", line 50, in open
        self.connection = connection_class(self.host, self.port, **connection_params)
      File "/usr/lib/python2.7/smtplib.py", line 249, in __init__
        (code, msg) = self.connect(host, port)
      File "/usr/lib/python2.7/smtplib.py", line 310, in connect
        (code, msg) = self.getreply()
      File "/usr/lib/python2.7/smtplib.py", line 361, in getreply
        raise SMTPServerDisconnected("Connection unexpectedly closed")
    SMTPServerDisconnected: Connection unexpectedly closed
    

can you help me solve this problem?


Answer: Please look into this Link: <https://code.djangoproject.com/ticket/9575> and
try sending via shell, it should work

