Hallo everyone at DaniWeb :)
A made a mail script, that i need to somehow break, to close the connection to the gmail server securely. Can someone give me a hint, what to do for that.
import smtplib import urllib2 import time def sendIP(): # fetch pub ip pub_ip = urllib2.urlopen("http://whatismyip.com/automation/n09230945.asp").read() msg = """Subject:Server ip! My ip today is: """ + pub_ip # Send mail server.sendmail(fromaddr, toaddrs, msg) print "The Master Is Informed" # Credentials fromaddr = '***@gmail.com' toaddrs = '***@gmail.com' username = '***' password = '***' # Start connection server = smtplib.SMTP('smtp.gmail.com:587') server.starttls() server.login(username,password) # This is the loop i need to break. I know there will be another problem with the sleep() : while 1: sendIP() time.sleep(25000) print "Connection Closed.." server.quit()