python smtplib set timeout -


I am trying to write small applications to send content status to my server every day, I am using smtplib I have a little problem with the bat, I can not know the connection timeout! Try Cubes smtp.setdefaulttimeout (30) BAT do not work

  try def connect (host, user, password): smtp = smtplib.SMTP (host) smtp.login (user, password) Code = Smtp.ehlo () [0] If no (200 =   

How to set connection timeout for this function? Thank you

With Python 2.6 you can set the timeout in the SMTP Library:

  class smtplib.SMTP ([host [, port [, local_hostname [, timeout]]]   

"if not specified, global default timeout setting"

If you use an earlier version of Python (& lt; 2.6), then you have to set the socket default timeout:

  import socket socket Setdefaulttimeout (120 )   

worked fine for me.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -