add_command('chown -R vmail:vmail ' . $maildir); add_command('chmod 744 ' . $maildir . '/Maildir/subscriptions'); add_command('chmod 600 ' . $maildir . '/Maildir/dovecot-*'); add_command('chmod 700 ' . $maildir . '/Maildir/cur ' . $maildir . '/Maildir/new ' . $maildir . '/Maildir/tmp'); add_command('chmod 600 ' . $maildir . '/Maildir/cur/* ' . $maildir . '/Maildir/new/* ' . $maildir . '/Maildir/tmp/*'); } $mail_ids[$entry['id']] = $new_id; } // select all redirs for this address $mail_redir = $exdb->queryAllRecords("SELECT id, mn_id, address FROM mail_redir WHERE mn_id = '" . $entry['id'] . "'"); foreach ($mail_redir as $redir) { $params = array('server_id' => $server_id, 'source' => $entry['mail_name'] . "@" . $parent_domain['name'], 'destination' => $redir['address'], 'type' => 'forward', 'active' => yes_no(1)); $old_mail = $app->db->queryOneRecord("SELECT forwarding_id FROM mail_forwarding WHERE source = '" . $entry['mail_name'] . "@" . $parent_domain['name'] . "' AND destination = '" . $redir['address'] . "'"); if ($old_mail) { $new_id = $old_mail['forwarding_id']; $ok = $importer->mail_forward_update($session_id, $client_id, $new_id, array_merge($old_mail, $params)); if ($ok === false) { $msg .= " Error: " . $importer->getFault() . "<br />"; } } else { $new_id = $importer->mail_forward_add($session_id, $client_id, $params); } if ($new_id === false) { //something went wrong here... $msg .= "Mail redirect " . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . " to " . $redir['address'] . ") could not be inserted/updated.<br />"; $msg .= " Error: " . $importer->getFault() . "<br />"; } else { $msg .= "Mail redirect " . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . " to " . $redir['address'] . ") inserted/updated.<br />"; } } unset($mail_redir);
//something went wrong here... $msg .= "Mail" . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . ") could not be inserted/updated.<br />"; $msg .= " Error: " . $importer->getFault() . "<br />"; } else { $msg .= "Mail " . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . ") inserted/updated.<br />"; } $mail_ids[$entry['id']] = $new_id; } // select all redirs for this address $mail_redir = $exdb->queryAllRecords("SELECT id, mn_id, address FROM mail_redir WHERE mn_id = '" . $entry['id'] . "'"); foreach ($mail_redir as $redir) { $params = array('server_id' => $server_id, 'source' => $entry['mail_name'] . "@" . $parent_domain['name'], 'destination' => $redir['address'], 'type' => 'forward', 'active' => yes_no(1)); $old_mail = $app->db->queryOneRecord("SELECT forwarding_id FROM mail_forwarding WHERE source = '" . $entry['mail_name'] . "@" . $parent_domain['name'] . "' AND destination = '" . $redir['address'] . "'"); if ($old_mail) { $new_id = $old_mail['forwarding_id']; $ok = $importer->mail_forward_update($session_id, $client_id, $new_id, $params); if ($ok === false) { $msg .= " Error: " . $importer->getFault() . "<br />"; } } else { $new_id = $importer->mail_forward_add($session_id, $client_id, $params); } if ($new_id === false) { //something went wrong here... $msg .= "Mail redirect " . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . " to " . $redir['address'] . ") could not be inserted/updated.<br />"; $msg .= " Error: " . $importer->getFault() . "<br />"; } else { $msg .= "Mail redirect " . $entry['id'] . " (" . $entry['mail_name'] . "@" . $parent_domain['name'] . " to " . $redir['address'] . ") inserted/updated.<br />"; } } unset($mail_redir);