Tcl Library Source Code

Documentation
Login


[ Main Table Of Contents | Table Of Contents | Keyword Index | Categories | Modules | Applications ]

NAME

imap4 - imap client-side tcl implementation of imap protocol

Table Of Contents

SYNOPSIS

package require Tcl 8.5
package require imap4 ?0.5.3?

::imap4::open hostname ?port?
::imap4::starttls chan
::imap4::login chan user pass
::imap4::folders chan ?-inline? ?mboxref? ?mboxname?
::imap4::select chan ?mailbox?
::imap4::examine chan ?mailbox?
::imap4::fetch chan range ?-inline? ?attr ...?
::imap4::noop chan
::imap4::check chan
::imap4::folderinfo chan ?info?
::imap4::msginfo chan msgid ?info? ?defval?
::imap4::mboxinfo chan ?info?
::imap4::isableto chan ?capability?
::imap4::create chan mailbox
::imap4::delete chan mailbox
::imap4::rename chan oldname newname
::imap4::subscribe chan mailbox
::imap4::unsubscribe chan mailbox
::imap4::search chan expr ?...?
::imap4::close chan
::imap4::cleanup chan
::imap4::debugmode chan ?errormsg?
::imap4::store chan range data flaglist
::imap4::expunge chan
::imap4::copy chan msgid mailbox
::imap4::logout chan

DESCRIPTION

The imap4 library package provides the client side of the Internet Message Access Protocol (IMAP) using standard sockets or secure connection via TLS/SSL. The package is fully implemented in Tcl.

This document describes the procedures and explains their usage.

PROCEDURES

This package defines the following public procedures:

EXAMPLES

set user myusername
set pass xtremescrt
set server imap.test.tld
set FOLDER INBOX
# Connect to server
set imap [::imap4::open $server]
::imap4::login $imap $user $pass
::imap4::select $imap $FOLDER
# Output all the information about that mailbox
foreach info [::imap4::mboxinfo $imap] {
    puts "$info -> [::imap4::mboxinfo $imap $info]"
}
# fetch 3 records inline
set fields {from: to: subject: size}
foreach rec [::imap4::fetch $imap :3 -inline {*}$fields] {
    puts -nonewline "#[incr idx])"
    for {set j 0} {$j<[llength $fields]} {incr j} {
        puts "\t[lindex $fields $j] [lindex $rec $j]"
    }
}

# Show all the information available about the message ID 1
puts "Available info about message 1: [::imap4::msginfo $imap 1]"

# Use the capability stuff
puts "Capabilities: [::imap4::isableto $imap]"
puts "Is able to imap4rev1? [::imap4::isableto $imap imap4rev1]"

# Cleanup
::imap4::cleanup $imap

TLS Security Considerations

This package uses the TLS package to handle the security for https urls and other socket connections.

Policy decisions like the set of protocols to support and what ciphers to use are not the responsibility of TLS, nor of this package itself however. Such decisions are the responsibility of whichever application is using the package, and are likely influenced by the set of servers the application will talk to as well.

For example, in light of the recent POODLE attack discovered by Google many servers will disable support for the SSLv3 protocol. To handle this change the applications using TLS must be patched, and not this package, nor TLS itself. Such a patch may be as simple as generally activating tls1 support, as shown in the example below.

package require tls
tls::init -tls1 1 ;# forcibly activate support for the TLS1 protocol

... your own application code ...

REFERENCES

Mark R. Crispin, "INTERNET MESSAGE ACCESS PROTOCOL - VERSION 4rev1", RFC 3501, March 2003, http://www.rfc-editor.org/rfc/rfc3501.txt

OpenSSL, http://www.openssl.org/

Bugs, Ideas, Feedback

This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category imap4 of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.

When proposing code changes, please provide unified diffs, i.e the output of diff -u.

Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. Only a small part of rfc3501 implemented.

SEE ALSO

ftp, http, imap, mime, pop3, tls

KEYWORDS

email, imap, internet, mail, net, rfc3501, ssl, tls

CATEGORY

Networking