Example #1
0
#---------------------------End Of Common stuff, which written once---------------------
#-----Example message that you are going to send, suppose, to client, that interested in your product:--
#Subject line:
#Welcome {$username}
#Body content:
#Welcome to our company
#Dear {$username} ,
#thank you for your interest in our product: {$product}
#Please, contact me for any further question
#contact email: {$salesemail}
#---------------------------Start of sending------------------------
#sending for particular subject
#construct subject parameters map
$subjMap = array("username" => "Peter");
#construct body parameters map
$bodyMap = array("username" => "Peter", "product" => "Samsung Note II", "salesemail" => "*****@*****.**");
#finally create a json string
#method parameters:
#1-par - subject params
#2-par - body params
#3-par - client e-mail
#4-par - template id
#5-par - template's language id
$jsonout = convertToJson($subjMap, $bodyMap, "*****@*****.**", "welcome", "en-US");
#send (by http post) to the DPost
#retured result: message accepted or not
#parameters:
#1-dpost url
#2-json content, including subject and body parameters and other e-mail parameters
$status_accepted = dpost_send($jsonout);
echo $status_accepted;
 /**
  * get the format content
  *
  * @param $encode_in_json bool
  *        	encode in Json
  */
 public function getFormatContent($encode_in_json)
 {
     if (!$encode_in_json && !is_array($this->content)) {
         $data_string = $this->content;
     } else {
         // transform the array in Json
         $data_string = convertToJson($this->content);
     }
     return $data_string;
 }