To send notification on some action from Splynx you can use hooks (Config/Integrations/Hooks).
Attention!!! beginning from Splynx v.1.3
First of all, you have to know how does it work. “Hook” is listening to event you choose and if it done, it runs script you wrote in “path”-field. By the way, hook can send data-array that call this event. Let’s create a new hook:
Before creating hook you have to put php-script in home-folder and give permissions 755:
chmod 755 script-file.php
And now, simple script - how to send email notification. Of course, you can use your own script that do something else.
#!/usr/bin/php
<?php
/*
* don`t edit this block !!!!
*/
// Define STDIN
defined('STDIN') OR define('STDIN', fopen('php://stdin', 'r'));
// Get all data. Its is in JSON so we must decode it
$data = fgets(STDIN);
// Decode JSON
$data = json_decode($data, true);
/*
* to send email edit this block
*/
$model = print_r($data,1); //print data-array
//send email
$to = "mail_box_to@semple.com" ; //set your email
$subject = "Splynx test send-mailer";
$message = "{$model} \n
Customer \"{$data['attributes']['name']}\" was created {$data['date']} by {$data['source']}";
$headers = "From: Admin <mail_box_from@semple.com>\r\n";
mail($to, $subject, $message, $headers);
So, when a new customer will be created, we will receive an email:
Attention!!!
To send email we used mail-server - Sendmail, and by default it send email only in local-network. So, if you want to send an email to “the world”, you have to reconfigure sendmail.
Run this command
sudo dpkg-reconfigure exim4-config
and use this manual - How To Install the Send-Only Mail Server "Exim" on Ubuntu 12.04 | DigitalOcean
That is all.
WBR, Splynx team.