I recently purchased a Raspberry Pi to run some Python scripts, but when I ported it the function I wrote to send emails through Windows Live suddenly started handing out an SSL error after successful handshake, specifically:
error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
After extensive searching around, I found many people with the same error, but all in vastly different situations. The most relevant thing I could find was that it seemed to be an issue with a specific version of OpenSSL, but I could find nothing about the version running on my Pi (1.0.1e).
The function (which works perfectly fine on Win7):
def wlive(adr_to, adr_fro, adr_pass, adr_subj, adr_file):
saveout = smtplib.stderr
logger = open('wlive.log', 'w')
smtplib.stderr = logger
msg = MIMEMultipart()
msg['Subject'] = adr_subj
msg['From'] = adr_fro
msg['To'] = adr_to
if adr_file != None:
# subtype recognition based on extension
filext = os.path.splitext(adr_file)[1]
if filext == '.png':
subt = 'png'
else:
subt = 'jpeg'
fp = open(adr_file, 'rb')
img = MIMEImage(fp.read(), subt)
fp.close()
msg.attach(img)
try:
server = smtplib.SMTP('smtp.live.com', 587)
server.set_debuglevel(1)
server.ehlo()
server.starttls()
server.login(adr_fro, adr_pass)
server.sendmail(adr_fro, adr_to, msg.as_string())
server.quit()
return True
except Exception, e:
print 'wlive exception:\n\n', str(e)
return False
smtplib.stderr = saveout
logger.close()
I'm running the fully updated and upgraded Raspbian "Wheezy" image, and Python 2.7.3
openssl version, thenopenssl s_client -connect smtp.live.com:587 -starttls smtpdo you get250 OK?