Enable DKIM by api

Discussion in 'Developers' Forum' started by Thaddeus, Jun 18, 2016.

  1. Thaddeus

    Thaddeus New Member

    I'm looking to enable DKIM by remote api. I can see the file mail_domain_dkim_create.php. What values would need to passed to do this? Or if anyone has a custom api, I'd be very grateful.
  2. florian030

    florian030 Well-Known Member HowtoForge Supporter

    AFAIK there is currently no function to create the dkim-keys.
    But you can create the key-pair yourself and insert the values using the remote-api für a maildomain.
    function pub_key($pubkey) {
      foreach($pubkey as $values) $public_key=$public_key.$values."\n";
      return $public_key;
    function get_public_key($private_key, $dkim_strength) {
      exec('echo '.escapeshellarg($private_key).'|openssl rsa -pubout -outform PEM 2> /dev/null',$pubkey,$result);
      return $public_key;
    $dkim_strength = 1024;
    $rnd_val = $dkim_strength * 10;
    exec('openssl rand -out ../../temp/random-data.bin '.$rnd_val.' 2> /dev/null', $output, $result);
    exec('openssl genrsa -rand ../../temp/random-data.bin '.$dkim_strength.' 2> /dev/null', $privkey, $result);
    foreach($privkey as $values) $private_key=$private_key.$values."\n";
    $public_key=get_public_key($private_key, $dkim_strength);
    Thaddeus likes this.
  3. Thaddeus

    Thaddeus New Member

    Thanks Florian. This will make it straight forward to accomplish

Share This Page