Best trigger for getting all domains/subdomains/aliases

  • Hello,


    I want to create a listener for configuring Postsrsd. The idea is to query the database for all available domains/subdomain/aliases with

    and to concat this to a string as parameter of postsrsd config.
    Generally this is no problem but I am wondering which trigger might be the best for starting the query as this would afterwards also trigger the reload as postsrsd. I was thinking about using afterNamedReload but that would trigger the listener every time a zone gets changed. Normally I just need the trigger when a new domain/subdomain/alias is added or deleted in order to reduce the reload commands towards postsrsd. If there is no special trigger which would fit this need, is it possible to register a listener to more than one trigger at the same time?
    Thanks in advance for your feedback.


    Regards Jörg

    (Ubuntu 16.04, i-MSCP 1.5.1, php-Fpm, Plugins: ClamAV, CronJobs, InstantSSH, LetsEncrypt, Mailgraph, Monitorix, OpenDKIM, PhpSwitcher, PolicydSPF, Postscreen, RecaptchaPMA, RoundcubePlugins, ServerDefaultPage, SpamAssassin, YubiKeyAuth)

  • @UncleJ


    Normally I just need the trigger when a new domain/subdomain/alias is added or deleted in order to reduce the reload commands towards postsrsd. If there is no special trigger which would fit this need

    The Postsrsd is a service for Postfix. Thus, you should listen on an event that is triggered by our Postfix server implementation.

    • The afterMtaAddDmn is triggered each time a domain has been added in postfix /etc/postfix/imscp/domains table
    • The afterMtaAddSub is triggered each time a subdomain has been added in postfix /etc/postfix/imscp/domains table
    • The afterMtaDelDmn is triggered each time a domain has been deleted from the /etc/postfix/imscp/domains table
    • The afterMtaDelSub is triggered each time a subdomain has been deleted from the /etc/postfix/imscp/domains table

    However, in your listener file, you should also test for the context (setup vs backend context). For the setup context, you should not listen on the same events because your service would be reloaded each time a domain is processed ;) To resume, in your listener, you should do something like:


    As you can see here, we register the same listener but depending on context, we listen on differents events. About your last question, I've answered it in the code sample.


    See also:

    And for your last question:

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

  • @Nuxwin,


    thanks for the information. I forgot about the way using the sub for triggering the listener as all contributed listeners recently removed this way and placed the code directly into the listener registration.


    Regards Jörg

    (Ubuntu 16.04, i-MSCP 1.5.1, php-Fpm, Plugins: ClamAV, CronJobs, InstantSSH, LetsEncrypt, Mailgraph, Monitorix, OpenDKIM, PhpSwitcher, PolicydSPF, Postscreen, RecaptchaPMA, RoundcubePlugins, ServerDefaultPage, SpamAssassin, YubiKeyAuth)