Remote API and multiple servers - adding mailboxes collides

Discussion in 'General' started by Danielh, Nov 8, 2017.

  1. Danielh

    Danielh New Member

    I have made a ispconfig setup for postfix/dovecot with a main server and a mirror server I also have a dedicated server for ispconfig panel to which I execute remote-api commands. The underlying storage is a nfs-mount from a gluster system. When I try to create mailboxes through the api some ends up in the corrupted folder and I have narrowed down the reason to being caused by the mirror server running crontab jobs at the same time as the master server and thus expecting folders that may not be created yet (this happens in fractions of seconds).

    My current solution is to add the mailboxes through the API while turning off crontab on the slave server, then when mailboxes are added I have to enable crontab again but I would like to get this working in a proper way. I also have no issues when adding mailboxes through ispconfig as a customer or administrator which leads me to believe this is some kind of bug or improper use of the API.

    Parts of my API-code can be found below which is based on the examples;

    $email = $_GET["email"];
    $client_id = $_GET["id"];
    $emailparts = explode("@", $email);
    $client = new SoapClient(null, array('location' => $soap_location,
    'uri' => $soap_uri,
    'trace' => 1,
    'exceptions' => 1));
    try {
    $session_id = $client->login($username,$password);
    $params = array(
    'server_id' => 8,
    'email' => $email,
    'login' => $email,
    'password' => $email_password,
    'name' => $email,
    'uid' => 5000,
    'gid' => 5000,
    'quota' => 5242880000,
    'cc' => '',
    'maildir' => '/var/vmail/'.$emailparts[1].'/'.$emailparts[0],
    'homedir' => '/var/vmail',
    'disablesmtp' => 'n',
    'access' => 'y',
    'postfix' => 'y',
    $affected_rows = $client->mail_user_add($session_id, $client_id, $params);

    Could you please advice on how to proceed with this issue? Thanks.

    With regards

Share This Page