Documentation can be found at http://tcllib.sourceforge.net/doc/pop3.html . package require pop3 ;# http://tcllib.sourceforge.net/ set popsock [pop3::open $_theHost $_theUser $_thePassword] foreach {msgcount size} [pop3::status $popsock] {} set message [pop3::retrieve $popsock $_index] set messages [pop3::retrieve $popsock $_first $_last] pop3::delete $popsock $_index pop3::delete $popsock $_first $_last pop3::close $popsock [[Add commentary to above. Explain [foreach] idiom. Mention exceptions.]] ---- [[Explain performance considerations, version compatibility, head use, exception-handling, ... Warn about deletes. Point to pertinent RFC for index base and other definitions.] ---- A little pop3 client demo, using the tcllib: Steve Offutt, 5/25/01 mailto:indmold@oz.sunflower.org Thanks to Cameron for help getting started. ---- # Check Mail - a lightweight pop3 client - Thursday May 31, 2001 package require pop3 #create a user interface proc make_gui { } { label .lhost -text "Hostname" label .luser -text "Username" label .lpass -text "Password" entry .eh -textvariable "_theHost" entry .eu -textvariable "_theUser" entry .ep -textvariable "_thePassword" bind .ep {open_channel} button .b -text "Connect" -command {open_channel} button .b2 -text "Disconnect" -command {close_it} set popsock "" label .lsock -text "Socket:" label .lsock2 -relief groove -bd 2 grid .lhost .eh -sticky ew grid .luser .eu -sticky ew grid .lpass .ep -sticky ew grid .lsock .lsock2 -row 3 -sticky ew grid .b -row 4 -columnspan 2 -sticky ew grid .b2 -row 5 -columnspan 2 -sticky ew .ep configure -show * } make_gui #globals global new_messages set new_messages 0 global popsock set popsock "" #procedures follow proc open_channel { } { global _theHost _theUser _thePassword popsock set popsock [pop3::open $_theHost $_theUser $_thePassword] .lsock2 configure -text $popsock get_status return $popsock } proc close_it { } { global popsock close $popsock set popsock "" .lsock2 configure -text "" return $popsock } proc get_status { } { global popsock set my_stat [pop3::status $popsock] set new_messages [lindex $my_stat 0] show_it $new_messages return $new_messages } proc show_it { var } { tk_messageBox -icon info -title "Messages" \ -parent . -type ok -message "You have $var new messages." #xception-handling, ... Warn about deletes. Point to pertinent RFC for index base and other definitions.] } proc tkerror { errmsg } { global errorCode set msg [format "Error: %s\nResult: %s." $errmsg $errorCode] tk_messageBox -parent . -title Error -type ok\ -icon error -message $msg bell } wm protocol . WM_DELETE_WINDOW "clean_up" proc clean_up { } { global popsock if {$popsock != ""} { close_it } exit } wm title . "Check Mail" wm deiconify . focus .eh ---- NOTE: Most pop3 servers only allow one client to connect at a time. That's what RFC 1939 [http://www.cis.ohio-state.edu/cgi-bin/rfc/rfc1939.html] requires. NOTE: RFC 1939 [ftp://ftp.isi.edu/in-notes/rfc1939.txt] (which is a standard) is ''updated'' by RFC 1957 [ftp://ftp.isi.edu/in-notes/rfc1957.txt] (informational), and RFC 2449 [ftp://ftp.isi.edu/in-notes/rfc2449.txt] (standards track). -'''EE''' (My information comes from http://www.rfc-editor.org/ , which is pretty much the canonical source of RFC information.) Only marginally on topic, we also have RFC 2384 [ftp://ftp.isi.edu/in-notes/rfc2384.txt]. ---- Remember, one doesn't do a package require of tcllib itself, but of the modules INSIDE tcllib... ---- If you had only an old, [socket]-less Tcl at hand, but also Expect, you could exploit the Unix telnet binary, as [Glenn Jackman]'s checkpopmail [http://www.magma.ca/~glennj/tcl/checkpopmail.exp] exemplifies. ---- [Category Package], subset [tcllib]