Search code examples
pythondjangodjango-1.4django-email

email.send() taking forever for manual connection


django 1.4 version

I know about send_email. But, I need to set manual connection for every email from db so using send() function.

from django.core.mail import EmailMessage, get_connection

e = EmailMessage('sub', 'body', to=['[email protected]'])

Now, it uses default connection.

I want to set connection at this point, so I did this:

e.connection =    get_connection(backend='django.core.mail.backends.smtp.EmailBackend', username='[email protected]', password='password', host='smtp.gmail.com', port=465, use_tls=True)

e.send() #taking forever(means hanging there without moving to next command) Why ?

Am I clear ?


Solution

  • Try changing the port argument to get_connection() from port=465 (SSL) to port=587 (TLS).