I-MSCP integrating with external system to create email accounts

  • Hello, I am trying to do an integration as the internal system of the company, where I can create email accounts directly through it from my domain "domain.com"


    I did the following:


    INSERT INTO `imscp`.`mail_users` (`mail_id`, `mail_acc`, `mail_pass`, `mail_forward`, `domain_id`, `mail_type`, `sub_id`, `status`, `mail_auto_respond`, `mail_auto_respond_text`, `quota`, `mail_addr`) VALUES (NULL, 'test', 'q1w2e3', '_no_', '1', 'normal_mail', '0', 'ok', '0', NULL, '11534336', '[email protected]');


    So far all right, I can access the webmail and send email without problem.
    However when I send an email to "[email protected]" informs the server that the user does not exist.


    =================
    Delivery to the following recipient failed permanently:
    [email protected]
    Technical details of permanent failure:
    Google tried to deliver your message, but it was rejected by the server for the recipient domain domain.com by mail.domain.com. [1.1.1.1].


    The error that the other server returned was:
    550 5.1.1 <[email protected]>: Recipient address rejected:
    User unknown in virtual mailbox table
    ==================


    This would be possible? I appreciate if someone can help me.


    Sorry for the english!

  • Re-run the setup to rebuild customers files...
    This system isn't intended to be used that way, if you add it only like that, you will only create the "panel" side email, but the system itself will not know them because they were NEVER created (you by-pass the base process of i-MSCP adding system, which run some backend command to add it to the system (Dovecot/postfix/courier/...)).


    If you don't wan't to have any trouble, add them manually on the panel ;)

  • @remontti


    What you want to do is possible but you must also set the mail_status field to toadd and trigger an i-MSCP backend request from your script. I can help you if you want. Join me on facebook. ;)

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206


  • Bonjour,


    Je serais aussi intéressé a trouver cette commande qui permet de modifier les fichiers de configuration de PostFix après un ajout de mail dans la db (avec statut : toadd).



    Je pensais sinon regarder du côté de l'extension remotebridge.. (Faire appel à la procédure iMSCP_Events::onAfterAddMail si possible)


    Merci d'avance,
    Bonne soirée,
    Cordialement,
    Florian

  • @gOOvER


    Here come the literal English translation of the @cflo56 post:


    Hello ;


    I would be also interested to find that command which allow to modify the Postfix configuration files after adding a mail account in the database (with the 'toadd' status).


    I thought to look to the side of the remotebridge plugin (listen on the iMSCP_Events::onAfterAddMail event if possible).


    Thank in advance,
    Good evening,
    Cordially,
    Florian

    badge.php?id=1239063037&bid=2518&key=1747635596&format=png&z=547451206

  • Sorry for my last post..


    Thanks @Nuxwin for translation
    (My English is not very good..)


    Currently, i continue to trying change the "remotebridge" plugins, but it is not easy. (I think it is possible)
    If you have an idea or command to allow modify the Postfix configuration, I am interested.


    In the meantime if I find the solution with remotebridge I allow myself to you provide on this topic


    Have a nice day !
    Cordially,
    Florian

  • This Solution with remotebridge :
    (simple example)


    - Add action :

    Code
    1. case 'createmail': createmail($postData['username'],$postData['mailadr'],$postData['password'],$postData['domainid']); break;


    - Add Function : (Warning, no syntax checking, no exist cheking.. etc)

    Code
    1. function createmail($username,$mailAddr,$password,$domainid){ $forwardList='_no_'; $mailType='normal_mail'; $subId=0; $quota=0; /** @var $db iMSCP_Database */ $db = iMSCP_Registry::get('db'); $cfg = iMSCP_Registry::get('config'); $auth = iMSCP_Authentication::getInstance(); iMSCP_Events_Aggregator::getInstance()->dispatch( iMSCP_Events::onBeforeAddMail, array('mailUsername' => $username, 'MailAddress' => $mailAddr) ); $query = ' INSERT INTO `mail_users` ( `mail_acc`, `mail_pass`, `mail_forward`, `domain_id`, `mail_type`, `sub_id`, `status`, `mail_auto_respond`, `mail_auto_respond_text`, `quota`, `mail_addr` ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) '; exec_query( $query, array( $username, $password, $forwardList, $domainid, $mailType, $subId, 'toadd', '0', NULL, $quota, $mailAddr ) ); $id =$db->insertId(); iMSCP_Events_Aggregator::getInstance()->dispatch( iMSCP_Events::onAfterAddMail, array('mailUsername' => $username, 'mailAddress' => $mailAddr, 'mailId' => $id) ); send_request(); logoutReseller(); exit( createJsonMessage( array( 'level' => 'Sucess', 'message' => 'Mail added.' ) ) );}


    Appel : (Example)