My apologies if this is the wrong place to ask this question. My Python
smtplib.py points to an invalid email address at
sendmail-bugs [at] sendmail.org and I ended up here.
My problem is trying to use the Python smtplib to access google mail.
This works:
IDLE 1.2.1
>>> import smtplib
>>> server = smtplib.SMTP('smtp.gmail.com',25)
>>> server.ehlo()
(250, 'mx.google.com at your service, [68.98.218.211]\nSIZE
28311552\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES')
>>> server.noop()
(250, '2.0.0 OK')
>>> server.quit()
>>>
But if I add a starttls() there is a failure on the quit(). Note that
the noop() below could be replaced with a login() and a sendmail() that
will execute successfully. The failure is on the quit():
>>> server = smtplib.SMTP('smtp.gmail.com',25)
>>> server.ehlo()
(250, 'mx.google.com at your service, [68.98.218.211]\nSIZE
28311552\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES')
>>> server.starttls()
(220, '2.0.0 Ready to start TLS')
>>> server.ehlo()
(250, 'mx.google.com at your service, [68.98.218.211]\nSIZE
28311552\n8BITMIME\nAUTH LOGIN PLAIN\nENHANCEDSTATUSCODES')
>>> server.noop()
(250, '2.0.0 OK')
>>> server.quit()
Traceback (most recent call last):
File "<pyshell#12>", line 1, in <module>
server.quit()
File "c:\Python25\lib\smtplib.py", line 716, in quit
self.docmd("quit")
File "c:\Python25\lib\smtplib.py", line 378, in docmd
return self.getreply()
File "c:\Python25\lib\smtplib.py", line 352, in getreply
line = self.file.readline()
File "c:\Python25\lib\smtplib.py", line 160, in readline
chr = self.sslobj.read(1)
sslerror: (1, 'error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong
version number')
>>>
I can avoid the traceback if I do a close instead of a quit (quit sends
a string "QUIT" and calls close):
>>> server = smtplib.SMTP('smtp.gmail.com',25)
>>> server.ehlo()
(250, 'mx.google.com at your service, [68.98.218.211]\nSIZE
28311552\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES')
>>> server.starttls()
(220, '2.0.0 Ready to start TLS')
>>> server.ehlo()
(250, 'mx.google.com at your service, [68.98.218.211]\nSIZE
28311552\n8BITMIME\nAUTH LOGIN PLAIN\nENHANCEDSTATUSCODES')
>>> server.noop()
(250, '2.0.0 OK')
>>> server.close()
>>>
This fails on Python 2.5 on Ubuntu and W/Vista. There is a report of
same failure here on Python 2.4.4:
http://moinmoin.wikiwikiweb.de/MoinAndGmail
The Python smtplib docs say to use quit() rather than close(). Any
suggestions as how to resolve this issue?
Roger
