* Univention: support Dovecot as IMAP available and default from 4.0-2 on

This commit is contained in:
Ralf Becker 2015-07-23 14:56:20 +00:00
parent 01391055dc
commit 2b1d3f63f3
2 changed files with 33 additions and 3 deletions

View File

@ -649,15 +649,27 @@ function set_univention_defaults()
$config['smtpserver'] = "$mailserver,465,,,yes,tls,no,yes";
$config['smtp'] = ',emailadmin_smtp_univention';
$config['mailserver'] = "$mailserver,993,$domain,email,tls";
$config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',emailadmin_imap_cyrus';
if (_ucr_get('mail/dovecot') == 'yes')
{
$config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',emailadmin_imap_dovecot';
// default with sieve port to 4190, as config is only available on host mailserver app is installed
if (!($sieve_port = _ucr_get('mail/dovecot/sieve/port'))) $sieve_port = 4190;
}
else
{
$config['imap'] = /*'cyrus,'._ucr_secret('cyrus')*/','.',emailadmin_imap_cyrus';
// default with sieve port to 4190, as config is only available on host mailserver app is installed
if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port'))) $sieve_port = 4190;
}
// set folders so mail creates them on first login, UCS does not automatic
$config['folder'] = 'INBOX/Sent,INBOX/Trash,INBOX/Drafts,INBOX/Templates,INBOX/Spam';
// default with sieve port to 4190, as config is only available on host mailserver app is installed
if (!($sieve_port = _ucr_get('mail/cyrus/sieve/port'))) $sieve_port = 4190;
$config['sieve'] = "$mailserver,$sieve_port,starttls";
// set an email address for sysop user so mail works right away
$config['admin_email'] = '$admin_user@'.$domain;
}
# add directory of univention-directory-manager and it's sysmlink target to open_basedir
system("/bin/sed -i 's|/usr/bin|/usr/bin:/usr/sbin:/usr/share/univention-directory-manager-tools|' /etc/egroupware/apache.conf");
}
}

View File

@ -27,6 +27,9 @@ class accounts_univention extends accounts_ldap
/**
* Name of binary to call
*
* It is a symlink to /usr/share/univention-directory-manager-tools/directory-manager-cli.
* Both directories must be included in open_basedir!
*/
const DIRECTORY_MANAGER_BIN = '/usr/sbin/univention-directory-manager';
@ -60,6 +63,21 @@ class accounts_univention extends accounts_ldap
if (!empty($data['account_passwd']))
{
$params[] = '--set'; $params[] = 'password='.$data['account_passwd'];
// we need to set mailHomeServer, so mailbox gets created for Dovecot
// get_default() does not work for Adminstrator, try acc_id=1 instead
// if everything fails try hostname ...
try {
if (!($account = emailadmin_account::get_default()))
{
$account = emailadmin_account::read(1);
}
$hostname = $account->acc_imap_host;
}
catch(Exception $e) {
unset($e);
}
if (empty($hostname)) $hostname = trunc(system('hostname -f'));
$params[] = '--set'; $params[] = 'mailHomeServer='.$hostname;
}
$cmd = self::DIRECTORY_MANAGER_BIN.' '.implode(' ', array_map('escapeshellarg', $params));
$output_arr = $ret = $matches = null;