1

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

3
  • openssl version, then openssl s_client -connect smtp.live.com:587 -starttls smtp do you get 250 OK? Commented Jun 10, 2013 at 19:23
  • Yeah, no issues whatsoever Commented Jun 14, 2013 at 20:33
  • Then it is probably more python related than libssl. To me it smells of incompatible ciphers configuration. I would try to dig that way. Commented Jun 15, 2013 at 11:56

1 Answer 1

1

I encountered this problem yesterday. First thing to try is to change the account from which you want to send an email to some other provider: try gmail, for instance. In my case it started working instantly.

If it's also the case for you (Microsoft's fault?), try another thing with windows live account (similar to the one suggested in the comment):
openssl s_client -connect smtp.live.com:587 -starttls smtp -crlf -ign_eof

then type:
ehlo
auth login
In my case nothing happened. No answer, only read timeout. This time try:
openssl s_client -connect smtp.live.com:587 -starttls smtp -crlf -ign_eof -no_tls1_2
Then:
ehlo
auth login
I got an answer immediately. If it's still your case, there's a little problem. I haven't found any way to specify such a parameter (which versions of tls to prevent from being used). What I found is that in python 3.3 you can give an additional context argument instarttls and you should be able to define some cipher parameters in this context. List of options can be found here.
I must admit that it was easier for me to just use the gmail account than to get python 3.3 (on rpi you've got 3.2 with no possibility of specifying the context), not being even sure if it will help. However, I hope that this information helps you somehow.

Sign up to request clarification or add additional context in comments.

1 Comment

The first line raises the wrong version number even right after ehlo, won't even let me login. The second string seems to work, I might just try to pass it through os.system and work from there if I can't find a way to specify it through the script

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.