[plt-scheme] SMTP/SSL

From: Matt Jadud (mcj4 at kent.ac.uk)
Date: Tue Aug 22 16:26:20 EDT 2006

I'm wondering if this should "just work," or if I need to do more work 
to send mail via SMTP through a host that uses TLS.

    (lib "head.ss" "net")
    (lib "smtp.ss" "net")
    (lib "mzssl.ss" "openssl"))

(let ([gmail-account <gmail-address>]
       [to <email-address>])
     (smtp-send-message "smtp.google.com"
                        (list to)
                        (standard-message-header gmail-account
                                                 (list to)
                                                 '() '()
                                                 "This is a test")
                        (map string->bytes/locale
                             (list "This message is a test."
                                   "It is only a test."))

                        #:port-no 25
                        #:auth-user gmail-account
                        #:auth-passwd <password-string>
                        #:tcp-connect ssl-connect))

This fails with

ssl-connect: connect failed (error:140770FC:SSL 
routines:SSL23_GET_SERVER_HELLO:unknown protocol)

If I replace "ssl-connect" with

(lambda (host port)
   (ssl-connect host port 'tls))

it fails with

ssl-connect: connect failed (error:1408F10B:SSL 
routines:SSL3_GET_RECORD:wrong version number)

which is the same error if I use 'sslv3. The ssl-connect times out if I 
use 'sslv2. I get the SSL23_GET_SERVER_HELO error if I use 'sslv2-or-v3.

I get the same errors on a host that uses Exim4.

I'm trying this on an up-to-date 10.4 installation. I'm unsure where I 
should start digging for a solution; it could be my SSL libraries, or 
something in the Scheme layer.



Posted on the users mailing list.