http://qs321.pair.com?node_id=542936

Plankton has asked for the wisdom of the Perl Monks concerning the following question:

Friends, I have a lot of IMAP mailboxes to create, so I thought I would use Cyrus::IMAP::Shell to run a script that would create them for me. Here's what I am doing along with the output I am getting ...

[plankton@mail1 SETUPIMAP]$ cat mbcreate connect mail1 cm user.userA cm user.userB ... [plankton@mail1 SETUPIMAP]$ perl -MCyrus::IMAP::Shell -e 'run("mbcreat +e")' cyradm> [plankton@mail1 SETUPIMAP]$ [plankton@mail1 SETUPIMAP]$ cyradm --user=cyrus mail1 IMAP Password: mail1.snakehandlers.net> lm user.plankton (\HasNoChildren) mail1.snakehandlers.net> quit [plankton@mail1 SETUPIMAP]$
... It seems to me that the mailboxes did not get created because I did not connect to imapd because I did not supply a password. Is that the case? If so how would I supply the password?

Thanks

Replies are listed 'Best First'.
Re: How do I pass the password to Cyrus::IMAP::Shell?
by Tomte (Priest) on Apr 13, 2006 at 16:27 UTC

    try the login command, see the documentation for the module.

    Otherwise, if you don't use the shell interactivly, why not use Cyrus::IMAP::Admin and do the full monty directly in perl?

    use Cyrus::IMAP::Admin; # # assuming all necessary variables have been declared and filled accor +dingly: # my $client = Cyrus::IMAP::Admin->new($host); my $auth = { -mechanism => 'login', -service => 'imap', -authz => $admin, -user => $admin, -minssf => 0, -maxssf => 10000, -password => $admin_pass, }; $client->authenticate( \%$auth); (print $client->{error} && return(1)) if $client->{error}; # e.g. create a new mailbox: $client->createmailbox('user.' . $mailuser);

    regards,
    tomte


    An intellectual is someone whose mind watches itself.
    -- Albert Camus

      Excellent script! I only had to remove the '\%' token in the authenticate call, and it worked like a charm. Any idea on how to set quota to that newly created mailbox? My guesses were all wrong! ;-) Thanks anyway! Juli
        Juli,

        Any idea on how to set quota to that newly created mailbox? My guesses were all wrong! ;-)

        The perldoc suggests

        # setting a 256MB quota $client->setquota('user.name@domain', 'STORAGE', 262144);
        Unfortunately I can't test this right now - but I'm sure other monks can help, if you post what you unsuccessfully tried.

        regards,
        tomte


        An intellectual is someone whose mind watches itself.
        -- Albert Camus

Re: How do I pass the password to Cyrus::IMAP::Shell?
by stonecolddevin (Parson) on Apr 13, 2006 at 05:51 UTC
    have you tried putting the password in a pretty envelope and leaving it with a glass of milk and some cookies on imapd's door step?
    meh.