Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29758

How to set Timeout for sending email using django?

$
0
0

I'm trying to set a timeout for sending email with Django. I'm using django 1.7.3 and python v2.7.6. My aproach was follow the django documentation in here. So what i did was create a custom email backend by creating a file named myemailbackend.py on django/core/mail/backends folder with the following code:

from django.core.mail.backends import smtp

class MyEmailBackend(smtp.EmailBackend):
  def __init__(self, *args, **kwargs):
      kwargs.setdefault('timeout', 3) #this is 3 secs, i believe.
      super(MyEmailBackend, self).__init__(*args, **kwargs)

After that in my settings.py i set my EMAIL_BACKEND:

# Email setup

EMAIL_BACKEND = 'django.core.mail.backends.base.myemailbackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'xxxx@gmail.com'
EMAIL_HOST_PASSWORD = 'xxx'
EMAIL_PORT = 587
# EMAIL_TIMEOUT = 3  # 3 sec, this would be great but i notice that this is not possible since that backend stmp.py doesn't expect to get "EMAIL_TIMEOUT" var.

After i runserver i've noticed that this doesn't seem to work, i notice to that myemailbackend.py didn't was compile. What am i'm missing? How can i set a timeout for send email, afterall?


Viewing all articles
Browse latest Browse all 29758

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>