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=['to@email.com'])
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@gmail.com', 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 ?
Try changing the port argument to get_connection()
from port=465
(SSL) to port=587
(TLS).