mail_forward_add - multiple domains

Discussion in 'General' started by pyte, Oct 7, 2022.

  1. pyte

    pyte Active Member HowtoForge Supporter

    once again i need some help understanding a function. The function "mail_forward_add" takes a array with the necessary options.
    $params = array(
    'server_id' => 1,
    'source' => '[email protected]',
    'destination' => '[email protected]',
    'type' => 'forward',
    'active' => 'y'
    I need to hand over multiple destinations, how can i achieve this? Can i pass over an array for destinations? In the webinterface it is possible to set multiple destinations.

    //Edit: Seems like it just takes a ',' seperated list for multiple destionations; trying and reporting back :)
    Last edited: Oct 7, 2022
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    If "," does not work, try \n instead.
    ahrasis likes this.
  3. pyte

    pyte Active Member HowtoForge Supporter

    That makes sense, however i didn't reach that point as of yet, because i don't understand the mail_domain table. Where is the relation to the customer in this table? The webinterface shows "Status, Customer, Server, Domain" under E-Mail Domains.

    I need to get the customer_no from an mail domain, so i thought i could just grab it like this

    -> $mr = mail_domain_get_by_domain(...)
    -> $cr = client_get(... $mr['client_id'] ...)

    But $mr does infact not contain the client_id, it contains the sys_userid what confuses me is that the sys_userid that is in the db is always exactly "customer_id + 1";

    i am a bit confused here, brain is lagging, can someone explain it for me?
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Most tables have the fields sys_user, sys_group, and sys_perm_*. This works similarly to Linux users file permissions. Each client has its own group in the sys_group table. To get the client of a mail domain, you must use the sys_groupid from mail_user table to look up the group in sys_group table and the sys_group table has a column for the client_id, which you can use to get the client record.

    To get a client for an email domain:

    $domain = 'example.tld';
    $maildomain = $remote->mail_domain_get($session_id, 'domain' => $domain);
    $client = $remote->client_get_by_groupid($session_id, $maildomain['sys_groupid']);
    untested :)

    That's by coincidence, the id's can differ completely.
    pyte and ahrasis like this.
  5. pyte

    pyte Active Member HowtoForge Supporter

    Thank you for the explanation! :)

Share This Page