Example #1
0
 /**
  * Sends a request with the specified $dyn variables to emailvision's system,
  * that will send a generated email to the $recipient.
  *
  * @param string   $template
  * @param string   $recipient
  * @param array    $dyn
  * @param array    $content
  * @param DateTime $date
  * @param int      $notificationId
  *
  * @throws Exception | \InvalidArgumentException
  */
 public function sendEmail($template, $recipient, array $dyn = array(), array $content = array(), \DateTime $date = null, $notificationId = 0)
 {
     try {
         if (!isset($this->emailvisionConfig[$template])) {
             throw new InvalidArgumentException(sprintf(self::ERROR_UNKNOWN_TEMPLATE, $template));
         }
         $date = $date instanceof \DateTime ?: new \DateTime();
         $client = new \SoapClient(self::WSDL_URL);
         $sendRequestObjects = $this->createSendRequestObject($recipient, $this->emailvisionConfig[$template], $this->arrayToEntries($content), $this->arrayToEntries($dyn), $date, $notificationId);
         $result = $client->sendObjectsWithFullStatus(array('arg0' => array($sendRequestObjects)));
         if ($result->return->element->responseStatus != self::SEND_REQUEST_SUCCESS_STATUS) {
             throw new Exception($result->return->element->result);
         }
     } catch (\SoapFault $e) {
         throw new Exception(sprintf(self::ERROR_SERVER, $e->getMessage()));
     }
 }