ISPconfig API - how to set / change Relayhost entries?

Discussion in 'General' started by awl, Mar 20, 2019.

  1. awl

    awl New Member

    I am trying to make use of the REST API in a bash script and got it basically working by adapting this example.
    Now I'm wondering how to make changes to the relayhost settings (System --> Server configuration --> E-Mail Tab) via API.

    The function list I get by issuing the remote command "get_function_list" lists four functions containing the string "relay", but none of them seems to be what I'm looking for. I was expecting something like mail_relayhost_get, mail_relayhost_user_set and so on, but nothing like that is in the list.

    Is it possible to inquire / change the relayhost settings remotely, and if yes, which are the names of the needed functions?
    Thanks in advance,
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The function you are seeking is named:

    system_config_set($session_id, $section, $key, $value)
  3. awl

    awl New Member

    Thank you!
    But I'm still guessing around. In /usr/local/ispconfig/interface/lib/classes/remote.d, I found:
    Set a value in the system configuration
    @param int session id
    @param string  section of the config field in the table. Could be 'web', 'dns', 'mail', 'dns', 'cron', etc
    @param string key of the option that you want to set
    @param string option value that you want to set
    This gives some orientation. For the beginning, I am trying only with system_config_get as it is less dangerous.
    One of my attempts (as middle part of the initally linked bash example):
    restCall system_config_get "{\"session_id\": \"$session_id\",\"section\": \"mail\",\"key\": \"relayhost_user\"}" | jq
    But I get:
      "code": "ok",
      "message": "",
      "response": false
    What is wrong?
    Last edited: Mar 21, 2019

Share This Page