By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

smtplib, gmail, quit vs. close and SSL3_GET_RECORD:wrong versionnumber

P: n/a
I am having a problem sending email through smtp.gmail.com using
smtplib. Everything works and the mail is sent and received, except
quit. The following shows the problem (without bothering to login or do
the sendmail):
>>>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.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#6>", 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 have not had this problem with other mail servers (but only tried
two). A solution for gmail seems to be to replace the server.quit()
with server.close(). The difference between the two commands is quit()
sends a 'QUIT' string before calling close(). Because close() is not
included in the smtplib docs, it does not appear to be the right solution.

What is the correct way to terminate a gmail session?

Roger
Aug 5 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.