2
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

EMAIL_HOST='smtp.gmail.com'
EMAIL_PORT=465
EMAIL_HOST_USER = 'yogi'
EMAIL_HOST_PASSWORD = '###'
DEFAULT_EMAIL_FROM = 'yogi@gmail.com'

above are the settings for django core mail module. I am using its send_mail to send mails to users. When i try to build the program with the gmail smtp it throws the following error

'Errno 10060 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond'.

I am doing this in my company and so it has proxy settings. I have given the proxy credentials in .condarc settings file. But still the connection timeout error. Do i need to set the proxy settings somewhere else or let me know where i am going wrong. ?

e4c5
  • 52,766
  • 11
  • 101
  • 134
Yogi
  • 1,561
  • 5
  • 26
  • 45
  • I would try to use another smtp server in order to see if the problem comes from gmail or your setup. Also a firewall (or even anti-virus) could block any smtp connection. – Geoffroy CALA Aug 03 '16 at 20:25
  • yes and when i try the same in my home it works completely fine. – Yogi Aug 05 '16 at 07:03
  • 1
    thats obviously because your home location does not have any restrictions on outgoing SMTP while your office clearly does. Did specifying a proxy as suggested work for you? Of course it still wouldn't work if your proxy does not allow the use of google smtp servers. – e4c5 Aug 06 '16 at 01:29

1 Answers1

1

As far as I know django does not detect any SMTP proxy settings from anaconda configuration files. You can overcome this by manually building a connection.

Notice that send_mail , has an option parameter for a connection. You get one by calling mail.get_connection now you need to wrap it around sockspi

see Python smtplib proxy support and Python send email behind a proxy server for further details.

Community
  • 1
  • 1
e4c5
  • 52,766
  • 11
  • 101
  • 134