The F#.NET Journal article An e-mail client in F# (31st March 2010) describes how you can write your own in just a few lines of F# code, centered around the following sequence expression:
> let receive =
seq { use client = new Sockets.TcpClient(Server.pop3.addr, Server.pop3.port)
use stream = client.GetStream()
use reader = new System.IO.StreamReader(stream)
let rec readToDot() =
let line = reader.ReadLine()
if line <> "." then line + "\n" + readToDot() else ""
reader.ReadLine() |> ignore
use writer = new System.IO.StreamWriter(stream)
let write (line: string) =
writer.Write(line + "\n")
writer.Flush()
write "USER myname"
reader.ReadLine() |> ignore // +OK Password required.
write "PASS mypassword"
reader.ReadLine() |> ignore // +OK logged in.
write "STAT"
let stat = reader.ReadLine() // +OK <message count> <total size>
for i in 1 .. int (stat.Split[|' '|]).[1] do
write(sprintf "RETR %d" i)
reader.ReadLine() |> ignore // +OK <message size> octets follow.
match readToDot() |> parse with
| Some msg -> yield msg
| None -> ()
write "QUIT"
reader.ReadLine() |> ignore };;
val receive : seq<msg>