On Sep 17, 5:04 pm, sui <[EMAIL PROTECTED]> wrote: > this is my code > > import sys, os, glob, datetime, time > import smtplib > ## Parameters for SMTP session > port=587 > SMTPserver= 'smtp.gmail.com' > SMTPuser= '[EMAIL PROTECTED]' > pw= 'fill in here' > SENDER= SMTPuser > > ## Message details > FROM= SENDER > TO= '[EMAIL PROTECTED]' > CC=FROM > ##RECEIVERS= (TO, CC) ##proper way to send to both TO and CC > RECEIVERS= (TO,) ## ignore the CC address > > subject= 'Test 1a' > message='*** Email test *** ' > > print 'Starting SMTP mail session on %s as %s ' % > (SMTPserver,SMTPuser) > session = smtplib.SMTP(SMTPserver,port) > session.set_debuglevel(0) # set debug level to 1 to see details > session.ehlo(SMTPuser) # say hello > session.starttls() # TLS needed > session.ehlo(SMTPuser) # say hello again, not sure why > session.login(SMTPuser, pw) > > ##Create HEADER + MESSAGE > HEADER= 'From: %s\r\n' % FROM > HEADER= HEADER + 'To: %s\r\n' % TO > HEADER= HEADER + 'Cc: %s\r\n' % CC > HEADER= HEADER + 'Subject: %s\r\n' % subject > BODY= HEADER + '\r\n' + message > print BODY > > SMTPresult = session.sendmail(SENDER, RECEIVERS, BODY) ## send email > > session.close() > > Now when i run this .py file...as python mail.py > i can see only statement > starting smtp mail......n details > then nothing on screen after few minutes or after pressing ctrl +c > Traceback (most recent call last): > File "mail4.py", line 21, in <module> > session = smtplib.SMTP(SMTPserver,port) > File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__ > (code, msg) = self.connect(host, port) > File "/usr/local/lib/python2.5/smtplib.py", line 301, in connect > self.sock.connect(sa) > File "<string>", line 1, in connect > or may be conncetion time out > > wats the solution for this
if i dont press cntrl + c then it shows Starting SMTP mail session on smtp.gmail.com as [EMAIL PROTECTED] Traceback (most recent call last): File "mail4.py", line 21, in <module> session = smtplib.SMTP(SMTPserver,port) File "/usr/local/lib/python2.5/smtplib.py", line 244, in __init__ (code, msg) = self.connect(host, port) File "/usr/local/lib/python2.5/smtplib.py", line 310, in connect raise socket.error, msg socket.error: (110, 'Connection timed out') plz help me its urgent.....i want to complete it as early as possible -- http://mail.python.org/mailman/listinfo/python-list