Skip to Main Content
Managing IMAP
book

Managing IMAP

by Dianna Mullet, Kevin Mullet
September 2000
Beginner content levelBeginner
408 pages
10h 29m
English
O'Reilly Media, Inc.
Content preview from Managing IMAP

createfolders

createfolders (shown in Example A-2 ) is a Tcl script that was used in Chapter 9 to create empty Cyrus mailboxes. It takes bsd2cyrus ’s output as input. bsd2cyrus ’s output contains the username, the pathname to a Berkeley-style mail folder, and its mapping into the Cyrus namespace (i.e., the Cyrus mailbox name), but createfolders uses only the Cyrus mailbox name.

Example A-2. createfolders

#!/usr/local/bin/cyradm -file
set inputfile [lindex $argv 0]

eval cyradm connect cyr_conn localhost imap
puts stdout "Connected to IMAP server. Authenticating..."

if [catch {eval cyr_conn authenticate -pwcommand {{
    set adminid "cyrus"
    set adminpw "xxxxxxxx"
    list $adminid $adminpw
}} } result ] {
    puts stderr "$result (cleartext)"
    return -code error $result
} else {
    puts "Authentication successful."
}

## $inputfile is a text file containing username, path to
## Berkeley format folder, and corresponding Cyrus mailbox

if [catch {open $inputfile r} fileId] {
    puts stderr "Error: cannot open $inputfile"
} else {

    while {[gets $fileId line] >= 0} {

        ## The Cyrus mailbox is the second field in the input 
        ## line (arrays are indexed starting with 0).

        set mailbox [lindex [split $line ":"] 1]

        if [catch {cyr_conn createmailbox $mailbox} result] {
            puts stderr $result
        } else {
            puts "Created mailbox $mailbox"
        }
    }
}
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Reinventing the Organization for GenAI and LLMs

Reinventing the Organization for GenAI and LLMs

Ethan Mollick
Why Sleep Is a Strategic Resource

Why Sleep Is a Strategic Resource

Gretchen Spreitzer, Christopher M. Barnes
The Kind Leader

The Kind Leader

Karyn Ross

Publisher Resources

ISBN: 059600012XSupplemental ContentCatalog PageErrata