[plt-scheme] Re: email using ssl

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Feb 23 16:26:32 EST 2007

At Wed, 21 Feb 2007 19:35:12 -0500, Stevie Strickland wrote:
> On Thu, Feb 22, 2007 at 05:44:30AM +0800, Matthew Flatt wrote:
> > [...] no one has
> > actually implemented it in "smtp.ss".
> [...] 
> I may see about trying my hand at it and getting you such a patch.

Thanks to Stevie for a patch and example use! I've applied the patch in
SVN, and the example is below.

The `smtp-send-message' function now accepts a #:tls-convert argument
that turns on TLS mode. The argument should normally be
`ports->ssl-ports' from "mzssl.ss" in the "openssl" collection.

(By having the caller supply the `ports->ssl-ports' function instead of
just #t, the STMP module avoids importing directly from the "openssl"
collection. Blame for this cheap linking trick goes to me, not Stevie.)



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

(let* ([account "me.myself"]
       [passwd "secret!"]
       [from (string-append account "@gmail.com")]
       [to "someone.else at someplace"])
     (smtp-send-message "smtp.gmail.com"
                        (list to)
                        (standard-message-header from
                                                 (list to)
                                                 '() '()
                                                 "This is a test")
                        (map string->bytes/locale
                             (list "This message is a test."
                                   "It is only a test."))
                        #:port-no 587
                        ;; Use TLS:
                        #:tls-encode ports->ssl-ports
                        ;; Supply username and password:
                        #:auth-user account
                        #:auth-passwd passwd))

Posted on the users mailing list.