[racket] pop3 connection

From: Nadeem Abdul Hamid (nadeem at acm.org)
Date: Thu Dec 16 19:36:39 EST 2010

The net/pop3 library doesn't seem to support ssl connections to a pop3
server. Here's a simple function that uses the openssl library to
connect to a server using ssl and attempt to login:

(require openssl)

(define (pop3auth username password [server "pop.gmail.com"])
  (let-values ([(inp outp) (ssl-connect server 995 'tls)])
    (read-line inp)   ; eats the "+OK ...." reply
    (write-string (string-append "USER " username "\r\n") outp)
    (read-line inp)
    (write-string (string-append "PASS " password "\r\n") outp)
    (let ([res (regexp-match #rx"^\\+OK" (read-line inp))])
      (write-string "QUIT\r\n" outp)
      (read-line inp)

(pop3auth "<username>" "<password>")
("+OK") if successful login, or
#f if failure.

You might be able to use ssl-connect as above to get input/output
ports and then manually make a 'communicator' structure that can be
used with the remaining functions of the net/pop3 library.

On Thu, Dec 16, 2010 at 12:41 AM, Sayed Khader <askhader at uwaterloo.ca> wrote:
> Hello
> I'm writing with regards to the net/pop3 library. I'm attempting to use it
> to pull emails from my gmail account. The connection I am trying to
> establish is very basic. As per the GMail connection specification
> (http://mail.google.com/support/bin/answer.py?hl=en&answer=13287) I make the
> following function call
> (define mp (connect-to-server "pop.gmail.com" 995))
> And after thirty or so seconds, I receive the following error
> regexp-match: expects type <string, byte string, or input port> as 2nd
> argument, given: #<eof>; other arguments were: #rx"^\\+OK(.*)"
> Any ideas?
> _________________________________________________
>  For list-related administrative tasks:
>  http://lists.racket-lang.org/listinfo/users

Nadeem Abdul Hamid
Associate Professor, Computer Science
Berry College
PO Box 5014
2277 Martha Berry Hwy NW
Mount Berry, GA 30149-5014
(706) 368-5632

Posted on the users mailing list.