source: trunk/doc-expressolivre/rhel5-centos5/arqs-conf-rhel5/cyrus.pl @ 67

Revision 67, 978 bytes checked in by niltonneto, 13 years ago (diff)

* empty log message *

  • Property svn:executable set to *
  • Property svn:mime-type set to application/octet-stream
Line 
1#!/usr/bin/perl -w
2
3# Author: <joao.alfredo@gmail.com>
4
5use Cyrus::IMAP::Admin;
6
7#
8# CONFIGURATION PARAMS
9#
10my $cyrus_server = "localhost";
11my $cyrus_user = "expresso-admin";
12my $user = "expresso-admin";
13my $mechanism = "login";
14
15if (!$ARGV[0]) {
16        die "Usage: $0 [expresso-admin password]\n";
17} else {
18        $cyrus_pass = "$ARGV[0]";
19}
20
21print "Criando usuario: $user. \n";
22createMailbox($user,'INBOX');
23createMailbox($user,'Enviados');
24createMailbox($user,'Lixeira');
25createMailbox($user,'Rascunhos');
26sub createMailbox {
27
28        my ($user, $subfolder) = @_;
29
30        my $cyrus = Cyrus::IMAP::Admin->new($cyrus_server);
31        $cyrus->authenticate($mechanism,'imap','',$cyrus_user,'0','10000',$cyrus_pass);
32
33        if ($subfolder eq "INBOX") {
34                $mailbox = "user/". $user;
35        } else {
36                $mailbox = "user/". $user ."/". $subfolder;
37        }
38
39        $cyrus->create($mailbox);
40        if ($cyrus->error) {
41                print STDERR "Error: ", $mailbox," ", $cyrus->error, "\n";
42        } else {
43                print "Mailbox $mailbox criada com êxito.\n";
44        }
45
46}
Note: See TracBrowser for help on using the repository browser.