Question

I've been trying to set up a django contact form on a simple blogging application which is currently hosted on Google cloud platform. The app seems to work locally, it sends an email out and redirects the end user to a completed page, however when I push it to the production server it tries to send an email for around 30s then times out and I get redirected to a 404. I've checked my nginx error and access logs as well as my gunicorn log and it seems that a gunicorn worker times out after 30 seconds, hence the 404. Initially I thought that this happens because my port 587 is locked on Google cloud network however even when I'm opening said port it still fails.

My settings.py:

Emailer EMAIL_HOST = "send.one.com" 
EMAIL_PORT = "587"
EMAIL_HOST_USER = "postman@email.co.uk"       
EMAIL_HOST_PASSWORD = "password"
DEFAULT_FROM_EMAIL = "postman@email.co.uk" 
SERVER_EMAIL = "postman@email.co.uk"

I've tried to run it through TLS by using EMAIL_USE_TLS = True But no success. Has anyone encountered this problem before?

Was it helpful?

Solution

App Engine blocks this kind of connection which opens socket.

You have 2 options if you want to send mails on Google App Engine:

  1. Directly use Mail API provided by Google App Engine, it will be a set of API that handles mailing on Google App Engine, for reference you can look here: Google App Engine Mail API for Python

  2. Use Django wrapper for GAE Mail API, like the one built in in rocket_engine or standalone one.

If you're doing this you can perform email sending in the same way of what Django does, it's more like a plugin could be installed into your Django project, then your settings will work without any change.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top