Package ProcImap :: Module ImapServer :: Class ImapServer
[hide private]
[frames] | no frames]

Class ImapServer

source code

A small lowlevel representation of an imap server

Public attributes are: servername address of the server username authentication username password authentication password port server port mailboxname currently active mailbox on the server

Instance Methods [hide private]
 
__init__(self, servername, username, password, ssl=True, port=None)
Initialize the IMAP Server, connect and log in.
source code
 
clone(self)
Return a new instance of ImapServer that points to the same server, in a connected and authenticated state.
source code
 
connect(self)
Connect to servername
source code
 
disconnect(self)
Disconnect from the server If looged in, log out
source code
 
login(self)
Identify the client using a plaintext password.
source code
 
reconnect(self)
Close and then reopen the connection to the server
source code
 
idle(self, timeout=5)
Put server into IDLE mode until server notifies some change, or 'timeout' (secs) occurs (default: 29 minutes), or another IMAP4 command is scheduled.
source code
 
create(self, name)
Create new mailbox
source code
 
delete(self, name)
Delete old mailbox
source code
 
subscribe(self, name)
Subscribe to new mailbox
source code
 
unsubscribe(self, name)
Unsubscribe from old mailbox
source code
 
logout(self)
Shutdown connection to server.
source code
 
append(self, mailbox, flags, date_time, messagestr)
Append message to named mailbox.
source code
 
uid(command, arg, ...)
Execute command with messages identified by UID.
source code
 
expunge(self)
Permanently remove deleted items from selected mailbox.
source code
 
close(self)
Close currently selected mailbox.
source code
 
select(self, mailbox='INBOX', create=False)
Select a mailbox.
source code
 
list(self)
Return list mailbox names, or None if the server does not send an 'OK' reply.
source code
 
lsub(self)
List subscribed mailbox names
source code
 
__eq__(self, other)
Equality test: servers are equal if they are equal in servername, username, password, port, and ssl.
source code
 
__ne__(self, other)
Inequality test: servers are unequal if they are not equal
source code
Method Details [hide private]

__init__(self, servername, username, password, ssl=True, port=None)
(Constructor)

source code 

Initialize the IMAP Server, connect and log in. If you leave the port unspecified, the default port will be used. This is port 143 is ssl is disabled, and port 933 if ssl is enabled.

clone(self)

source code 
Return a new instance of ImapServer that points to the same server,
in a connected and authenticated state.

    >>> server1 = ImapServer('localhost','user','secret')
    >>> server2 = ImapServer('localhost','user','secret')
is equivalant to
    >>> server1 = ImapServer('localhost','user','secret')
    >>> server2 = server1.clone()

login(self)

source code 

Identify the client using a plaintext password. The password will be quoted. Connect to the server is not connected already. If any problems occur during a login attempt, this method may cause a reconnect to the server.

logout(self)

source code 

Shutdown connection to server. Returns server "BYE" response.

append(self, mailbox, flags, date_time, messagestr)

source code 

Append message to named mailbox. All parameters are strings which need to be in the appropriate format as described in RFC3501

uid(command, arg, ...)

source code 

Execute command with messages identified by UID. Returns response appropriate to command.

expunge(self)

source code 

Permanently remove deleted items from selected mailbox. Generates an "EXPUNGE" response for each deleted message. Returned data contains a list of "EXPUNGE" message numbers in order received.

close(self)

source code 

Close currently selected mailbox. Deleted messages are removed from writable mailbox. This is the recommended command before "LOGOUT".

select(self, mailbox='INBOX', create=False)

source code 

Select a mailbox. Log in if not logged in already. Return number of messages in mailbox if successful. If the mailbox does not exist, create it if 'create' is True, else raise NoSuchMailboxError. The name of the mailbox will be stored in the mailboxname attribute if selection was successful