PHP Cyradm extension - Re: Add mailbox automatically

Kervin L. Pierre kervin at blueprint-tech.com
Wed Jan 1 18:27:49 EST 2003


Thanks. I didn't know you could do that.

BTW, I browsed the PHP manual for more IMAP stuff and came across a 
Cyradm extension http://www.php.net/manual/en/ref.cyrus.php .

It is undocumented.  Has anyone used this extension with success??

--Kervin



Scott Russell wrote:
> On Wed, Jan 01, 2003 at 05:16:12PM -0500, Kervin L. Pierre wrote:
> 
>>Just a thought,
>>
>>I am working on some PHP scripts to manage mailboxes and I have to use 
>>passthough calls to execute cyradm to add mailboxes.
>>
>>I'd like to avoid opening a shell from the web for security and 
>>performance reasons.
>>
> 
> 
> Here's a PHP function that I use to create user mailboxes with. It
> could use some clean up but it works for us. Beware line wraps.
> 
> function imap_acct_create ($mailbox, $quota="") {
>     // creates user.$mailbox in cyrus 2.1.5
>     global $imap_error;
>     $imap = @imap_open("{localhost:143/imap/notls}", "cyrus", "passwd", OP_HALFOPEN);
>     if (!$imap) { 
>         $imap_error = imap_last_error(); 
>         return FALSE; 
>     }
>     // create the new top level mailbox
>     $ret = @imap_createmailbox($imap, "{localhost}user.".$mailbox);
>     if (!$ret) { $imap_error = imap_last_error(); 
>         @imap_close($imap);
>         return FALSE; 
>     }
>     // if needed, set the account quota
>     if ($quota != "") {
>         $ret = @imap_set_quota($imap, "user.".$mailbox, $quota);
>         if (!$ret) { $imap_error = imap_last_error(); 
> 	@imap_close($imap); return FALSE; }
>     }
>     @imap_close($imap);
>     // if we get here everything worked
>     return TRUE;
> }   
> 


-- 

=========================
Kervin Pierre

kervin at blueprint-tech.com
kervin at kervin.net
kpierre at fit.edu






More information about the Info-cyrus mailing list