[plug] deleting mail using imap

Craig Ringer craig at postnewspapers.com.au
Sun Apr 18 17:21:55 WST 2004


On Sun, 2004-04-18 at 16:57, Craig Ringer wrote:

> If you server doesn't support permit plaintext authentication, you can
> use Python's imaplib module to do much the same thing from an
> interactive python prompt, but using SSL. You'll need Python 2.3 for
> imaplib.IMAP4_SSL support.

Example:

[craig at albert craig]$ python2.3
Python 2.3.3 (#1, Feb  7 2004, 17:28:49)
[GCC 3.3.2 20031022 (Red Hat Linux 3.3.2-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import imaplib
>>> conn = imaplib.IMAP4_SSL("mailserver")
>>> conn.login("craig","xxxxxxxxx")
('OK', ['User logged in'])
>>> conn.select("INBOX")
('OK', ['57'])
>>> conn.expunge()
('OK', ['50', '50', '50', '51', '51', '51'])
>>> conn.logout()
('BYE', ['LOGOUT received'])

tip: in the Python interpeter, run 'help(imaplib)' for a useful summary.

--
Craig Ringer




More information about the plug mailing list