djangoauthenticationdjango-registration

Django registration SMTPServerDisconnected error


I use django-registration for my project to manage user registration, login, etc. But When I sign up for an account I came across this problem:

SMTPServerDisconnected

For the record, I did configure email related settings in my settings.py:

EMAIL_HOST = 'smtp.gmail.com'                                                                                                                                           
EMAIL_PORT = 465
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'myemail@gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'

Also I have all the templates needed and accessible. So this problem doesn't have anything to do with that.

More Error description:

After I click on the send activation email, it takes a long time before it finally give that error.

Here is the traceback (not complete):

SMTPServerDisconnected at /accounts/register/

Connection unexpectedly closed

last trace back:

/usr/lib/python2.7/smtplib.py in getreply

                    line = self.file.readline()

                except socket.error as e:

                    self.close()

                    raise SMTPServerDisconnected("Connection unexpectedly closed: "

                                                 + str(e))

                if line == '':

                    self.close()

                    raise SMTPServerDisconnected("Connection unexpectedly closed")

    ...

                if self.debuglevel > 0:

                    print>>stderr, 'reply:', repr(line)

                resp.append(line[4:].strip())

                code = line[:3]

                # Check that the error code is syntactically correct.

                # Don't attempt to read a continuation line if it is broken.

Thanks for any suggestion.


Solution

  • I think at least one setting is incorrect. Port 587 is required for TLS [1]

    EMAIL_PORT = 587

    [1] http://support.google.com/mail/bin/answer.py?hl=en&answer=13287