Mail samples

Basics

On most methods you'll see parameter named "mailId". The value of this parameter can be a valid mail UUID or path.

Example of fldId:

  • Using UUID -> "520f4d98-1855-4784-9bc3-01ba5b440c1d";
  • Using path -> "/okm:root/2937b81d-0b10-4dd0-a426-9acbd80be1c9-some subject"

Methods

createMail

Description:

MethodReturn valuesDescription

createMail(Mail $mail)

Mail

Creates a new mail and returns as a result an object Mail.

The variable path into the parameter mail, must be initializated. It indicates the folder path into OpenKM.

Other mandatory variables:

  • size ( mail size in bytes ).
  • from ( mail from account ).
  • reply, to, cc, bcc ( mail accounts are optional ).
  • sendDate ( date when mail was sent ).
  • receivedDate ( date when was received ).
  • subject ( mail subject ).
  • content ( the mail content ).
  • mimeType ( HTML or text mime type ).
  • headers ( the mail headers are optional).
  • raw ( the mail raw are optional).
  • origin ( msg, eml, api, pop3, imap origin )
  • title ( mail title )

Mails account allowed formats:

  • "\"John King\" <jking@mail.com>"
  • "<jking@mail.com>"

Mail path allowed is:

MSGID . "-" . sanitized(subject).

MIME types values:

  • Mail::MIME_TEXT for text mail format.
  • Mail::MIME_HTML for html mail format.

Origin values:

  • Mail::ORIGIN_MSG for .msg mail format.
  • Mail::ORIGIN_EML for .eml mail format.
  • Mail::ORIGIN_API for mail format created from API.
  • Mail::ORIGIN_POP3 for mail imported from pop3 account.
  • Mail::ORIGIN_IMAP for mail imported from imap account.

The other variables of Mail ( mail ) will not take any effect on mail creation.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testCreateMail() {
        try {
            $mail = new \openkm\bean\Mail();
            // Mail path = msgId + escaped(subject)
            $msgId = "2937b81d-0b10-4dd0-a426-9acbd80be1c9";
            $subject = "some subject";
            $mailPath = "/okm:root/SDK4PHP/" . $msgId . "-" . $this->escape($subject);
            $mail->setPath($mailPath);
            // Other format for mail "some name <no_reply@openkm.com>"
            $mail->setFrom('<no_reply@openkm.com>');
            $mail->setTo(['anonymous@gmail.com', 'anonymous1@gmail.com']);
            // You should set real dates
            $mail->setSentDate(date('Y-m-d'));
            $mail->setReceivedDate(date('Y-m-d'));
            $mail->setContent('some content');
            $mail->setMimeType(\openkm\bean\Mail::MIME_TEXT);
            $mail->setSubject($subject);
            $mail->setOrigin(\openkm\bean\Mail::ORIGIN_API);
            // Get only as an approximation of real size for these sample
            $mail->setSize(strlen($mail->toString()));
            var_dump($this->ws->createMail($mail));
        } catch (Exception $e) {
            var_dump($e);
        }
    }


    private function escape($name) {
        $ret = $this->cleanup($name);
        return htmlentities($ret);
    }

    private function cleanup($name) {
        $ret = str_replace('/', '', $name);
        $ret = str_replace('*', '', $ret);
        $ret = str_replace('\\s+', ' ', $ret);
        return $ret;
    }


}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testCreateMail();
?>

getMailProperties

Description:

MethodReturn valuesDescription

getMailProperties($mailId)

Mail

Returns the mail properties.

Parameters:
$mailId
string type is the uuid or path of the Mail

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetMailProperties() {
        try {
            $mail = $this->ws->getMailProperties('520f4d98-1855-4784-9bc3-01ba5b440c1d');
            var_dump($mail);
        } catch (Exception $e) {
            var_dump($e);
        }
    }   
}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testGetMailProperties();
?>

deleteMail

Description:

MethodReturn valuesDescription

deleteMail($mailId)

void

Deletes a mail.

Parameters:
$mailId
string type is the uuid or path of the Mail

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testDeleteMail() {
        try {
            $this->ws->deleteMail('520f4d98-1855-4784-9bc3-01ba5b440c1d');
            echo 'deleted';
        } catch (Exception $e) {
            var_dump($e);
        }
    }
}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testDeleteMail();
?>

renameMail

Description:

MethodReturn valuesDescription

renameMail($mailId, $newName)

Mail

Change the name of a Mail and returns the Mail

Parameters:
$mailId
string type is the uuid or path of the Mail

$newName string type is the new name for the Mail

From OpenKM frontend UI the subject is used to show the mail name at file browser table. That means this change will take effect internally on mail path, but will not be appreciated from default UI.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testRenameMail() {
        try {
            $mail = $this->ws->renameMail('520f4d98-1855-4784-9bc3-01ba5b440c1d', 'new name');
            var_dump($mail);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testRenameMail();
?>

moveMail

Description:

MethodReturn valuesDescription

moveMail($mailId, $dstId)

void

Moves mail into a folder or record.

Parameters:
$mailId
string type is the uuid or path of the Mail

$dstId string type is the uuid or path of the Folder or Record

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testMoveMail() {
        try {
            $this->ws->moveMail('520f4d98-1855-4784-9bc3-01ba5b440c1d', '/okm:root/SDK4PHP/tmp');
            echo 'move';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testMoveMail();
?>

getMailChildren

Description:

MethodReturn valuesDescription

 getMailChildren($fldId)

array

Returns a list of all mails which their parent is fldId.

Parameters:
$fldId
string type is the uuid or path of the Folder or a record node.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetMailChildren() {
        try {
            $mails = $this->ws->getMailChildren('/okm:root/SDK4PHP');
            foreach ($mails as $mail) {
                var_dump($mail);
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testGetMailChildren();
?>

isValidMail

Description:

MethodReturn valuesDescription

isValidMail($mailId)

bool

Returns a boolean that indicate if the node is a mail or not.

Parameters:
$mailId
string type is the uuid or path of the Mail

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testIsValidMail() {
        try {
            //Return false
            var_dump($this->ws->isValidMail('/okm:root/SDK4PHP/logo.png'));
            //Return true
            var_dump($this->ws->isValidMail('520f4d98-1855-4784-9bc3-01ba5b440c1d'));
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testIsValidMail();
?>

getMailPath

Description:

MethodReturn valuesDescription

getMailPath($uuid)

string

Converts mail UUID to mail path.

Parameters:
$uuid
string type is the uuid of the Mail

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetMailPath() {
        try {
            var_dump($this->ws->getMailPath('520f4d98-1855-4784-9bc3-01ba5b440c1d'));
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testGetMailPath();
?>

createAttachment

Description:

MethodReturn valuesDescription

createAttachment($mailId, $docName, $content)

Document

Stores into the mail an attachment and returns an object Document with the properties of the created attachment.

Parameters:
$mailId
string type is the uuid or path of the Mail

$docName string type is the Name of the Attachment

$content string type is recommend using file_get_contents — Reads entire file into a string

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testCreateAttachment() {
        try {
            $fileName = dirname(__FILE__) . '/files/logo.png';
            $docName = 'logo.png';
            $document = $this->ws->createAttachment('520f4d98-1855-4784-9bc3-01ba5b440c1d', $docName, file_get_contents($fileName));
            var_dump($document);
        } catch (Exception $e) {
            var_dump($e);
        }
    }   

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testCreateAttachment();
?>

deleteAttachment

Description:

MethodReturn valuesDescription

deleteAttachment($mailId, $docId)

void

Deletes a mail attachment.

Parameters:
$mailId
string type is the uuid or path of the Mail

$docId string type is the uuid or path of the Document

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testDeleteAttachment() {
        try {
            $this->ws->deleteAttachment('520f4d98-1855-4784-9bc3-01ba5b440c1d', '73ba1f80-4769-492b-ab15-0ecfbb15d6ac');
            echo 'deleted attachment';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testDeleteAttachment();
?>

getAttachments

Description:

MethodReturn valuesDescription

getAttachments(String mailId)

array

Retrieves a list of all documents attachment of a mail.

Parameters:
$mailId
string type is the uuid or path of the Mail

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testGetAttachments() {
        try {
            $documents = $this->ws->getAttachments('520f4d98-1855-4784-9bc3-01ba5b440c1d');
            foreach ($documents as $document) {
                var_dump($document);
            }
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testGetAttachments();
?>

purgeMail

Description:

MethodReturn valuesDescription

purgeMail($mailId)

void

Mail is definitely removed from repository.

Parameters:
$mailId
string type is the uuid or path of the Mail

Usually you will purge mails into /okm:trash/userId - the personal trash user locations - but is possible to directly purge any mail from the whole repository.

When a mail is purged only will be able to be restored from a previously repository backup. The purge action remove the mail definitely from the repository.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testPurgeMail() {
        try {
            $this->ws->purgeMail('520f4d98-1855-4784-9bc3-01ba5b440c1d');
            echo 'purge';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testPurgeMail();
?>

copyMail

Description:

MethodReturn valuesDescription

public void copyMail($mailId, $dstId, $newName)

void

Copies mail into a folder or record.

Parameters:
$mailId
string type is the uuid or path of the Mail

$dstId string type is the uuid or path of the Folder or Record

$newName string type is the new name for the Document

When parameter newName value is null, mail will preserve the same name.

Only the security grants are copied to destination, the metadata, keywords, etc. of the folder are not copied.

See "extendedMailCopy" method for this feature.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testCopyMail() {
        try {
            $this->ws->copyMail('520f4d98-1855-4784-9bc3-01ba5b440c1d', '/okm:root/SDK4PHP/tmp', 'new_name');
            echo 'copyMail';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testCopyMail();
?>

extendedMailCopy

Description:

MethodReturn valuesDescription

extendedMailCopy($mailId, $dstId, $categories, $keywords, $propertyGroups, $notes,
            $wiki, $newName)

void

Copies mail width with associated data into a folder or record.

Parameters:
$mailId
string type is the uuid or path of the Mail

$dstId string type is the uuid or path of the Folder or Record

$categories bool type

$keywords bool type

$propertyGroups bool type

$notes bool type

$wiki bool type

$newName string type is the new name for the Mail. Value is null, mail will preserve the same name.

By default only the binary data and the security grants, the metadata, keywords, etc. of the folder are not copied.

Additional:

  • When the category parameter is true the original values of the categories will be copied.
  • When the keywords parameter is true the original values of the keywords will be copied.
  • When the propertyGroups parameter is true the original values of the metadata groups will be copied.
  • When the notes parameter is true the original values of the notes will be copied.
  • When the wiki parameter is true the original values of the wiki will be copied.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testExtendedMailCopy() {
        try {
            $this->ws->extendedMailCopy('3c19ceb2-9c6a-4b43-aabb-7f169127022a', '/okm:root/SDK4PHP/tmp', true, true, true, true, true, 'new_name_copy');
            echo 'extendedMailCopy';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testExtendedMailCopy();
?>

sendMailWithAttachments

Description:

MethodReturn valuesDescription

sendMailWithAttachments($subject, $body, $dstId, $toRecipients, $ccRecipients, $bccRecipients, $docsId)

void

Sends mail message with attachement.

Parameters:
$subject
string type is the mail subject

$body string type is the message of the email

$dstId string type is the uuid or path of the Folder or Record

$toRecipients array type are a array of mail accounts destination

$ccRecipients array type are a array of mail accounts destination (optinal)

$bccRecipients array type are a array of mail accounts destination (optional)

$docsId array type are a array of valid document UUID already into OpenKM that will be send as attachment into mail ( optional ).

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testSendMailWithAttachments() {
        try {
            $to = ['destination@gmail.com','destination1@gmail.com'];
            $cc = ['destination3@gmail.com','destination4@gmail.com'];
            $bcc = ['destination5@gmail.com','destination6@gmail.com'];            
            $docsId = ['f123a950-0329-4d62-8328-0ff500fd42db','/okm:root/SDK4PHP/logo.png'];
            $this->ws->sendMailWithAttachments('some suject', 'some body', '/okm:root/SDK4PHP/tmp', $to, $cc, $bcc, $docsId);
            echo 'sendMailWithAttachemetns';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testSendMailWithAttachments();
?>

importEml

Description:

MethodReturn valuesDescription

importEml($dstId, $title, $content)

Mail

Import a mail in EML format.

Parameters:
$dstId
string type is the uuid or path of the Folder or Record. The dstId parameter indicate where the mail will be stored in the repository after is sent.

$title string type is the title of the Mail.

$content string type is recommend using file_get_contents — Reads entire file into a string

Example:

<?php

include '../src/openkm/OpenKM.php';

ini_set('display_errors', true);
error_reporting(E_ALL);

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testImportEml() {
        try {
            $fileName = dirname(__FILE__) . '/files/test.eml';            
            $mail = $this->ws->importEml('768748c5-04ab-4921-b0d4-7545d239ce5a', 'some title', file_get_contents($fileName));
            var_dump($mail);
        } catch (Exception $e) {
            var_dump($e);
        }
    }   

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testImportEml();
?>

importMsg

Description:

MethodReturn valuesDescription

importMsg($dstId, $title, $content)

Mail

Import a mail in MSG format.

Parameters:
$dstId
string type is the uuid or path of the Folder or Record. The dstId parameter indicate where the mail will be stored in the repository after is sent.

$title string type is the title of the Mail.

$content string type is recommend using file_get_contents — Reads entire file into a string

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testImportMsg() {
        try {
            $fileName = dirname(__FILE__) . '/files/test.eml';            
            $mail = $this->ws->importEml('702e456a-3145-4dd5-831d-01647a9f2608', 'some title', file_get_contents($fileName));
            var_dump($mail);
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testImportMsg();
?>

setMailTitle

Description:

MethodReturn valuesDescription

setMailTitle($mailId, $title)

void

Import a mail in MSG format.

Parameters:
$mailId
string type is the uuid or path of the Mail

$title string type is the title of the Mail.

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testSetMailTitle() {
        try {
            $this->ws->setMailTitle('3c19ceb2-9c6a-4b43-aabb-7f169127022a', 'some title');
            echo 'mail title';
        } catch (Exception $e) {
            var_dump($e);
        }
    }
}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testSetMailTitle();
?>

 sendMail

Description:

MethodReturn valuesDescription

sendMail($subject, $body, $recipients)

void

Sends a mail.

Parameters:
$subject
string type is the mail subject

$body string type is the message of the email.

$recipients string type is array of mail accounts destination

Example:

<?php

include '../src/openkm/OpenKM.php';

use openkm\OKMWebServicesFactory;
use openkm\OpenKM;

class ExampleMail {

    const HOST = "http://localhost:8080/OpenKM/";
    const USER = "okmAdmin";
    const PASSWORD = "admin";

    private $ws;

    public function __construct() {
        $this->ws = OKMWebServicesFactory::build(self::HOST, self::USER, self::PASSWORD);
    }

    public function testSendMail() {
        try {
            $recipients = array();
            $recipients[] = 'gnu.java.sergio@gmail.com';
            $recipients[] = 'sochoa@openkm.com';
            $this->ws->sendMail('Testing sending mail from OpenKM', 'Test message body.', $recipients);
            echo 'send Mail';
        } catch (Exception $e) {
            var_dump($e);
        }
    }

}

$openkm = new OpenKM(); //autoload
$exampleMail = new ExampleMail();
$exampleMail->testSendMail();
?>