Import mail users from another system

  • Hi,

    I would like to import a large number of email accounts ("normal" and "forward") into i-MSCP. The customer and domain already exist in i-MSCP.

    I've read gui/public/client/mail_add.php to get an idea how email accounts are added by the GUI, and for me it looks that it is not a problem to manually add new records to the mail_users database table with the 'toadd' status.

    However, I am not exactly sure if I fully understand what the EventsManager does, and if I can trigger its function manually.

    1. EventsManager::getInstance()->dispatch(Events::onBeforeAddMail, [
    2. 'mailUsername' => $username,
    3. 'MailAddress' => $mailAddr
    4. ]);

    1. EventsManager::getInstance()->dispatch(Events::onAfterAddMail, [
    2. 'mailUsername' => $username,
    3. 'mailAddress' => $mailAddr,
    4. 'mailId' => $db->insertId()
    5. ]);
    6. send_request();

    Could anyone give me a short hint if this is possible at all, how this is best done, or where I can find some more info on the EventsManager?

    (Im running the latest version (1.5.3) of i-MSCP on Debian 9).

    Thank you,