471,337 Members | 845 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,337 software developers and data experts.

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

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)
(250, 'mx.google.com at your service, []\nSIZE 28311552\n8BITMIME\nSTARTTLS\nENHANCEDSTATUSCODES' )
(220, '2.0.0 Ready to start TLS')
(250, 'mx.google.com at your service, []\nSIZE 28311552\n8BITMIME\nAUTH LOGIN PLAIN\nENHANCEDSTATUSCODES')
(250, '2.0.0 OK')

Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
File "c:\Python25\lib\smtplib.py", line 716, in 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?

Aug 5 '07 #1
0 1646

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by nephish | last post: by
6 posts views Thread by Max | last post: by
7 posts views Thread by 3KWA | last post: by
8 posts views Thread by NicolasG | last post: by
2 posts views Thread by carlistixx | last post: by
reply views Thread by cher | last post: by
reply views Thread by 7stud | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.