Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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

try

server.ehlo('user.name@gmail.com')

in both places above

also look at setting

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top