Tutorial :Sending email using google apps SMTP server in Python 2.4


I'm having difficulty getting python 2.4 to connect to gmail's smtp server. My below script doesn't ever get past "connection". I realise there is an SMTP_SSL class in later versions of python and it seems to work fine, but the production environment I have to deal with only has - and likely will only ever have - python 2.4.

print "connecting"  server = smtplib.SMTP("smtp.gmail.com", 465)    print "ehlo"  server.ehlo()  print "start tls"  server.starttls()    print "ehlo"  server.ehlo()  print "log in"  if self.smtpuser:      server.login(smtpuser, smtppassword)  

Does anybody have any advice for getting the above code to work with python 2.4?


When I tried setting something similar up for Django apps, I could never get it to work on port 465. Using port 587, which is the other port listed in the GMail docs seemed to work.


Yes I used 587 as the port for my vb.net app too. 465 did not work for me too.




in both places above

also look at setting

server.set_debuglevel(1) value as required for more info

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »