Connect. Communicate. Collaborate. Securely.

Home » Kerio User Forums » Kerio Connect » Kerio Connect API - Smtp.setRelayDeliveryRulesList
  •  
etrusco.net

Messages: 3
Karma: 0
Send a private message to this user
Hello,
I'm new here.
I have a problem with Kerio Connect API.
I used Delivery.setPop3Account to change email password and it works very well.
Now I want to use Smtp.setRelayDeliveryRuleList to change accounts' password for the SMTP Configuration but I've some trouble because I don't understand how it work.
I try to pass a RelayDeliveryRule array:

array(7) {
  ["id"]=> string 
  ["isEnabled"]=> bool
  ["description"]=> string 
  ["hostName"]=> string
  ["port"]=> int
  ["authentication"]=> array(4) {
    ["isRequired"]=> bool
    ["userName"]=> string
    ["password"]=> string
    ["authType"]=> string
  }
  ["condition"]=> array(3) {
    ["test"]=> string
    ["comparator"]=> string
    ["pattern"]=> string
  }
}


but I get ever the error message "Invalid params" for any array that I pass to the method.

Is there someone who can help me?

Thanks for reading this far.

[Updated on: Fri, 28 October 2016 12:00]


I'm sorry
I'm not English and so my english is awful lol
  •  
Brian Carmichael (Kerio)

Messages: 559
Karma: 55
Send a private message to this user
You can use your browser to inspect the JSON request from the web admin. Then you can use an online tool to convert the JSON string to a PHP array. I did this, and the resulting output looked like this. I hope it helps.

array (
  'jsonrpc' => '2.0',
  'id' => 1,
  'method' => 'Batch.run',
  'params' => 
  array (
    'commandList' => 
    array (
      0 => 
      array (
        'method' => 'Smtp.set',
        'params' => 
        array (
          'server' => 
          array (
            'relayControl' => 
            array (
              'ipAddressGroupId' => '',
            ),
            'ipBasedLimit' => 
            array (
            ),
          ),
        ),
      ),
      1 => 
      array (
        'method' => 'Smtp.setRelayDeliveryRuleList',
        'params' => 
        array (
          'list' => 
          array (
            0 => 
            array (
              'description' => 'My delivery rule',
              'hostName' => 'smtp.example.com',
              'port' => 25,
              'isEnabled' => true,
              'authentication' => 
              array (
                'isRequired' => true,
                'userName' => 'admin',
                'password' => 'secretpassword',
                'authType' => 'Auth',
              ),
              'condition' => 
              array (
                'test' => 'RelayCondSender',
                'comparator' => 'RelayCompEqual',
                'pattern' => '*<_at_>example.com',
              ),
              'id' => '',
            ),
          ),
        ),
      ),
    ),
  ),
)

[Updated on: Fri, 28 October 2016 18:09]


Brian Carmichael
Senior Technical Marketing Engineer | Kerio
Stay Connected Anytime, Anywhere. Discover Kerio Cloud!
  •  
etrusco.net

Messages: 3
Karma: 0
Send a private message to this user
Thanks for your answer.

I tried it and it works, but I've a problem: I've 4 SMTP Relay and I want to change password to only one.

If I use the code above I lose all my Relay SMTP and I can't change the password to one of them.

[Updated on: Mon, 31 October 2016 15:12]


I'm sorry
I'm not English and so my english is awful lol
  •  
Brian Carmichael (Kerio)

Messages: 559
Karma: 55
Send a private message to this user
Ok I see the issue. You have to first list all of the rules to get their IDs.

array (
  'jsonrpc' => '2.0',
  'id' => 1,
  'method' => 'Smtp.getRelayDeliveryRuleList',
  'params' => 
  array (
    'query' => 
    array (
      'start' => 0,
      'limit' => -1,
    ),
  ),
)


Then you have to return the entire list in your next query, along with the rule you're adding or updating. If you're adding a new rule then the ID is empty, but for all other rules (that you're not updating) you need to provide only the ID.

array (
  'jsonrpc' => '2.0',
  'id' => 1,
  'method' => 'Batch.run',
  'params' => 
  array (
    'commandList' => 
    array (
      0 => 
      array (
        'method' => 'Smtp.set',
        'params' => 
        array (
          'server' => 
          array (
            'relayControl' => 
            array (
            ),
            'ipBasedLimit' => 
            array (
            ),
          ),
        ),
      ),
      1 => 
      array (
        'method' => 'Smtp.setRelayDeliveryRuleList',
        'params' => 
        array (
          'list' => 
          array (
            0 => 
            array (
              'description' => 'server 2',
              'hostName' => 'relay.example.com',
              'port' => 25,
              'isEnabled' => true,
              'authentication' => 
              array (
                'isRequired' => true,
                'userName' => 'admin',
                'password' => 'abc123',
                'authType' => 'Auth',
              ),
              'condition' => 
              array (
                'test' => 'RelayCondSender',
                'comparator' => 'RelayCompEqual',
                'pattern' => '*<_at_>example.com',
              ),
              'id' => '',
            ),
            1 => 
            array (
              'id' => 'keriodb://relaydeliveryrule/b450da57-3310-4947-9ea2-5b839eedb065',
            ),
          ),
        ),
      ),
    ),
  ),
)

Brian Carmichael
Senior Technical Marketing Engineer | Kerio
Stay Connected Anytime, Anywhere. Discover Kerio Cloud!
  •  
etrusco.net

Messages: 3
Karma: 0
Send a private message to this user
Now it works.
Thanks Brian.


I'm sorry
I'm not English and so my english is awful lol
Previous Topic: LDAP Connection to special OU - login failure at webclient
Next Topic: Smtp Transaction Time Issue
Goto Forum:
  


Disclaimer:
Kerio discussion forums are intended for open communication between forum members and may contain information and material posted by members which may be useful in learning about Kerio products. The discussion forums are not intended to provide technical support for any specific product. Any information implied or expressed in the discussion forums is that of the posting member. Kerio is in no way responsible for the information posted in the forums, or its accuracy. Kerio employees may participate in the discussions, but their postings do not represent an offical position of the company on any issues raised or discussed. Kerio reserves the right to monitor and maintain the forums to promote free and accurate exchange of information.

Current Time: Fri Dec 09 16:25:15 CET 2016

Total time taken to generate the page: 0.00958 seconds
.:: Contact :: Home ::.
Powered by: FUDforum 3.0.4.