コード例 #1
0
 /**
  * send mail
  *
  * array or object of type you set while initialize service
  * @param Object|array $mail
  *
  * @throws \Exception $ex
  *
  * @return Mail
  */
 public function sendMail($mail)
 {
     if (!is_array($mail)) {
         try {
             $arrayMail = $mail->toArray();
         } catch (\Exception $ex) {
             throw new \Exception('impossible to convert ' . get_class($mail) . ' to mail array');
         }
     } else {
         $arrayMail = $mail;
     }
     $this->openTransport();
     $header = $arrayMail['header'];
     $sendingMail = $this->convertor->convertToSendFormat($arrayMail);
     //        prn($sendingMail->toString());
     try {
         $this->transport->send($sendingMail);
     } catch (\Exception $ex) {
         //create checking exception to output normal view, that describes problem to user
         throw new \Exception('Mail format exception. Asc administrator to fix the problem');
         //            throw $ex;
     }
     $headers = $sendingMail->getHeaders()->toArray();
     if (isset($headers['Message-ID'])) {
         $header['message-id'] = $headers['Message-ID'];
     }
     if (is_array($mail)) {
         $mail['header'] = $header;
     } else {
         $mail->header = $header;
     }
     $this->closeTransport();
     return $mail;
 }
コード例 #2
0
ファイル: subscription.php プロジェクト: vosaan/ankor.local
 public function haltForm(Object $Object, $method = 'edit')
 {
     if ($method == 'add') {
         if ($Object->Id) {
             $Object->send();
         }
     }
     return parent::haltForm($Object, $method);
 }
コード例 #3
0
ファイル: MailerTest.php プロジェクト: kobabasu/rest-slim
 /**
  * 正常系 ログファイルのパスが取得できるか
  *
  * @covers Lib\SwiftMailer\Mailer::getPath()
  * @test testSetGetPath()
  */
 public function testSetGetPath()
 {
     $body = 'hello twig';
     $this->object->setFrom($GLOBALS['MAIL_FROM']);
     $this->object->setName($GLOBALS['MAIL_NAME']);
     $this->object->setMessage('タイトル', $body);
     $this->object->send('*****@*****.**');
     $res = $this->object->getPath();
     $this->assertInternalType('string', $res);
 }
コード例 #4
0
 /**
  * 正常系 添付画像を含むメッセージを返すか
  *
  * @covers Lib\SwiftMailer\Mailer::send()
  * @test testSetSendAttachmentNormal()
  */
 public function testSendAttachmentNormal()
 {
     $body = $this->object->setTemplate('defaultTest.twig', array('name' => '太郎'));
     $this->object->setAttachment('tests/imgs/test.jpg', 'image/jpeg', 'test');
     $this->object->setFrom($GLOBALS['MAIL_FROM']);
     $this->object->setName($GLOBALS['MAIL_NAME']);
     $this->object->setMessage('添付画像テスト', $body);
     $res = $this->object->send('*****@*****.**');
     $this->assertEquals(1, $res);
 }
コード例 #5
0
 /** Send message via connector to recorder host.
  *
  * @param $payload
  */
 public function send(\StdClass $payload)
 {
     $this->connector->send($payload);
 }
コード例 #6
0
ファイル: cheese.php プロジェクト: hannenz/cheese
 /**
  * Main dispatcher
  * 
  * @return void
  */
 public function run()
 {
     /* Only Ajax requests allowed */
     if (!$this->Request->isAjax()) {
         die('No direct access!');
     }
     /* Check if an action is given */
     if (empty($this->Request->data['action'])) {
         $ret = json_encode(array('success' => false, 'message' => 'No action specified'));
         print_r($ret);
         die;
     }
     /* Dispatch the action */
     switch ($this->Request->data['action']) {
         case 'take_foto':
             $data = $this->Camera->takeFoto();
             if (empty($data)) {
                 $this->Response->setError('Failed to take a foto');
             } else {
                 $this->Response->setPayload($data);
             }
             break;
         case 'hardcopy':
             $this->hardcopy($_POST['filename']);
             break;
         case 'cancel':
             echo "Starting over...";
             die;
             // unset($_SESSION);
             // session_destory();
             break;
         case 'save_picture':
             if (!empty($this->Request->data['imageData'])) {
                 $im = imagecreatefromstring(base64_decode(substr($this->Request->data['imageData'], 22)));
                 if ($im === false) {
                     $this->Response->setError('imagecreatefromstring() failed');
                 } else {
                     $filename = __DIR__ . DIRECTORY_SEPARATOR . 'pictures' . DIRECTORY_SEPARATOR . uniqid() . '.jpg';
                     if (!imagejpeg($im, $filename, 100)) {
                         $this->Response->setError('imagejpeg() failed');
                     } else {
                         $this->Response->setMessage($filename);
                     }
                 }
                 imagedestroy($im);
             }
             break;
         case 'get_camera_option':
             $attr = $_GET['attr'];
             $val = shell_exec(sprintf('/usr/bin/v4l2-ctl --get-ctrl %s', $attr));
             $this->Response->setMessage($val);
             break;
         case 'set_camera_option':
             $attr = $_GET['attr'];
             $value = intval($_GET['val']);
             shell_exec(sprintf('/usr/bin/v4l2-ctl --set-ctrl %s=%d', $attr, $value));
             break;
             // case 'startvideostream':
             // 	$this->Camera->startVideoStream();
             // 	break;
             // case 'stopvideostream':
             // 	$this->Camera->stopVideoStream();
             // 	break;
         // case 'startvideostream':
         // 	$this->Camera->startVideoStream();
         // 	break;
         // case 'stopvideostream':
         // 	$this->Camera->stopVideoStream();
         // 	break;
         default:
             $this->Response->setError('Invalid action: ' . $this->Request->data['action']);
     }
     $this->Response->send();
 }
コード例 #7
0
ファイル: Client.php プロジェクト: noeldavies/trafficlive
 /**
  * Fetch the response from the request
  *
  * @version 1.0
  * @since   1.0
  * @author  Daniel Noel-Davies
  *
  * @param   Object  $request       Guzzle Request Object 
  *
  * @return  Object  Guzzle Response
  */
 public static function getResponse($request)
 {
     return \Cache::remember($request->getUrl(), 60, function () use($request) {
         // Send the request and store the response
         try {
             $response = $request->send();
         } catch (\Guzzle\Http\Exception\ServerErrorResponseException $e) {
             \Cache::forget($request->getUrl());
             sleep(5);
             $response = self::getResponse($request);
         }
         return $response;
     });
 }