15.1Class IMAP

IMAP class.

Class IMAP( server, [port],[timeout] )
server Server address.
port Port number (default 143).
timeout Socket timeout in milliseconds (default 1000).
Properties
oldReply
portPort number.
reply
selectedCurrent selected mailbox.
serverServer address.
stateCurrent state (see IMAPState).
timeoutTimeout (in milliseconds) waiting for server contact.
traceFunction used to show communication between client and server.
Methods
closeClose selected mailbox.
connectConnect to IMAP server.
createCreate a mailbox.
deleteDelete a mailbox.
expungeExpunge a mailbox.
fetchFetch data associated with a message.
getBodyGet a whole message.
getBodySectionGet a section of a message.
getFlagsGet the flags associated with a message.
getHierarchyDelimiterGet the hierarchy delimiter.
getSizeGet the RFC822 size of a message.
loginLogin procedure.
logoutLogout procedure.
lstList mailboxes.
lsubList subscribed mailboxes.
renameRename a mailbox.
searchSearch for messages.
selSelect a mailbox.
subscribeSubscribe to a mailbox.
unsubscribeUnsubscribe to a mailbox.

Properties

oldReply

port

Port number.

reply

selected

Current selected mailbox.

server

Server address.

state

Current state (see IMAPState).

timeout

Timeout (in milliseconds) waiting for server contact.

trace

Function used to show communication between client and server.

Methods

close

Close selected mailbox.

close()
Raise
IMAPError Close failure.

connect

Connect to IMAP server.

connect()
Raise
IMAPError Unable to connect.

create

Create a mailbox.

create( mailbox )
mailbox The mailbox to create.
Raise
IMAPError Create failure.

delete

Delete a mailbox.

delete( mailbox )
mailbox The mailbox to delete.
Raise
IMAPError Delete failure.

expunge

Expunge a mailbox.

expunge()
Raise
IMAPError Expunge failure.

fetch

Fetch data associated with a message.

fetch( msg_set, [msg_parts] )
msg_set Message id or a sequence of message ids.
msg_parts message data item names or macro (default FAST).
Returnthe raw data.
Raise
IMAPError Fetch failure.

That is a raw, 'low-level' function returning the untreated answer got from the server. More appropriate functions are the IMAP.get* functions.

See also: http.

getBody

Get a whole message.

getBody( msg_id )
msg_id The message id.
ReturnThe whole message.
Raise
IMAPError Fetch failed.

getBodySection

Get a section of a message.

getBodySection( msg_id, section )
msg_id The message id.
section The desired section.
Raise
IMAPError Fetch failed.

Examples:


         imap.getBodySection( 1, 'HEADER' ) # get header
         imap.getBodySection( 3, '1.HEADER' ) # get header of first part
         imap.getBodySection( 5, 3 ) # get third part...

getFlags

Get the flags associated with a message.

getFlags( msg_id )
msg_id The message id.
ReturnA list of flags.
Raise
IMAPError Fetch failed.

getHierarchyDelimiter

Get the hierarchy delimiter.

getHierarchyDelimiter( [ref] )
ref The reference (default "").
ReturnThe character used as hierarchy delimiter.

getSize

Get the RFC822 size of a message.

getSize( msg_id )
msg_id The message id.
ReturnThe message size.
Raise
IMAPError Fetch failed.

login

Login procedure.

login( user, pasw )
user username.
pasw password.
Raise
IMAPError Login failure.

Connection attempt will be performed if not already done.

logout

Logout procedure.

logout()
Raise
IMAPError Logout failure.

lst

List mailboxes.

lst( [dir],[pattern] )
dir Reference directory (default "").
pattern Search pattern (default "").
ReturnA list of mailboxes information.
Raise
IMAPError List failure.

lsub

List subscribed mailboxes.

lsub( [dir],[pattern] )
dir Reference directory (default "").
pattern Search pattern (default "").
ReturnA list of subscribed mailboxes names.
Raise
IMAPError Lsub failure.

rename

Rename a mailbox.

rename( oldbox, newbox )
oldbox The actual mailbox to rename.
newbox The desired mailbox name.
Raise
IMAPError Rename failure.

search

Search for messages.

search( [criterion],[charset] )
criterion Search criteria (default ALL).
charset Optional charset specification.
ReturnA list of message ids matching the criteria.
Raise
IMAPError Search failure.

sel

Select a mailbox.

sel( [mailbox],[readonly] )
mailbox The mailbox to select (default INBOX).
readonly (boolean) Default false.
Raise
IMAPError Select failure.

subscribe

Subscribe to a mailbox.

subscribe( mailbox )
mailbox The mailbox to subscribe to.
Raise
IMAPError Subscribe failure.

unsubscribe

Unsubscribe to a mailbox.

unsubscribe( mailbox )
mailbox The mailbox to unsubscribe to.
Raise
IMAPError Unsubscribe failure.
Made with http://www.falconpl.org