Overview

Packages

  • None
  • Vilma

Classes

  • Vilma
  • Vilma_Api
  • Vilma_Driver
  • Vilma_Driver_Qmailldap
  • Vilma_Driver_Sql
  • Vilma_Form_DeleteDomain
  • Vilma_Form_EditAlias
  • Vilma_Form_EditDomain
  • Vilma_Form_EditForward
  • Vilma_Form_EditUser
  • Vilma_MailboxDriver
  • Vilma_MailboxDriver_Hooks
  • Vilma_MailboxDriver_Imap
  • Vilma_MailboxDriver_Maildrop
  • Vilma_MailboxDriver_Null
  • Vilma_Test
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Copyright 2004-2012 Horde LLC (http://www.horde.org/)
 4:  *
 5:  * See the enclosed file LICENSE for license information (BSD). If you did not
 6:  * did not receive this file, see http://cvs.horde.org/co.php/vilma/LICENSE.
 7:  *
 8:  * @author  Jason M. Felice <jason.m.felice@gmail.com>
 9:  * @package Vilma
10:  */
11: class Vilma_MailboxDriver_Maildrop extends Vilma_MailboxDriver
12: {
13:     /**
14:      * Creates a new mailbox.
15:      *
16:      * @param string $user    The name of the mailbox to create.
17:      * @param string $domain  The name of the domain in which to create the
18:      *                        mailbox.
19:      *
20:      * @throws Vilma_Exception
21:      */
22:     public function createMailbox($user, $domain)
23:     {
24:         if (empty($this->_params['system_user'])) {
25:             throw new Vilma_Exception(_("No 'system_user' parameter specified to maildrop driver."));
26:         }
27: 
28:         $shell = sprintf('sudo -u %s maildirmake %s',
29:                          escapeshellarg($this->_params['system_user']),
30:                          escapeshellarg($this->_getMailboxDir($user, $domain)));
31:         exec($shell);
32:     }
33: 
34:     /**
35:      * Deletes an existing mailbox.
36:      *
37:      * @todo
38:      *
39:      * @param string $user    The name of the mailbox to delete.
40:      * @param string $domain  The name of the domain in which to delete the
41:      *                        mailbox.
42:      *
43:      * @throws Vilma_Exception
44:      */
45:     public function deleteMailbox($user, $domain)
46:     {
47:     }
48: 
49:     /**
50:      * Checks whether a mailbox exists and is set up properly.
51:      *
52:      * @param string $user    The name of the mailbox to check.
53:      * @param string $domain  The mailbox' domain.
54:      *
55:      * @return boolean  True if the mailbox exists.
56:      * @throws Vilma_Exception if the mailbox doesn't exist or a parameter is
57:      *                         missing
58:      */
59:     public function checkMailbox($user, $domain)
60:     {
61:         $dir = $this->_getMailboxDir($user, $domain);
62: 
63:         if (!is_dir($dir)) {
64:             throw new Vilma_Exception(sprintf(_("Maildrop directory \"%s\" does not exist."), $dir));
65:         }
66: 
67:         return true;
68:     }
69: 
70:     /**
71:      * @throws Vilma_Exception
72:      */
73:     protected function _getMailboxDir($user, $domain)
74:     {
75:         if (empty($this->_params['mail_dir_base'])) {
76:             throw new Vilma_Exception(_("No 'mail_dir_base' parameter specified to maildrop driver."));
77:         }
78: 
79:         $dir = $this->_params['mail_dir_base'];
80:         if (!empty($this->_params['usedomain'])) {
81:             $dir .= '/' . $domain;
82:         }
83: 
84:         return $dir . '/' . $user;
85:     }
86: }
87: 
API documentation generated by ApiGen