예제 #1
0
 public function testGetWrongPart()
 {
     $message = new Zend_Mail_Message(array('file' => $this->_file));
     try {
         $message->getPart(-1);
     } catch (Exception $e) {
         return;
         // ok
     }
     $this->fail('no exception raised while fetching unknown part');
 }
예제 #2
0
 /**
  * メール読み取り
  */
 public static function readMail()
 {
     // 標準入力から読み取り
     $message = new Zend_Mail_Message(array('file' => 'php://stdin'));
     $obj = array();
     // 差出人
     $obj['from'] = self::getMailAddress($message->from);
     // 宛先
     $obj['to'] = self::getMailAddress($message->to);
     // 件名
     if ($message->getHeader('subject')) {
         $obj['subject'] = $message->subject;
     } else {
         $obj['subject'] = '';
     }
     // 本文
     $obj['body'] = $message->getContent();
     // 不正なメールアドレスなので無視
     if (preg_match("/^MAILER\\-DAEMON\\@/i", $obj['from']) || preg_match("/^postmaster\\@/i", $obj['from']) || $obj['from'] === '*****@*****.**' || strlen($obj['from']) === 0 || !preg_match("/.+\\@[a-zA-Z0-9][a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]+\$/", $obj['from'])) {
         exit;
     }
     // 添付ファイル処理
     if ($message->isMultipart()) {
         // 添付ファイル数
         $obj['files'] = $message->countParts() - 1;
         // 添付ファイル
         for ($i = 2; $i <= $message->countParts(); $i++) {
             $obj['files_type_' . ($i - 2)] = $message->getPart($i)->getHeader('content-type');
             $obj['files_body_' . ($i - 2)] = $message->getPart($i)->getContent();
         }
     } else {
         // 添付ファイル数
         $obj['files'] = 0;
     }
     return $obj;
 }
예제 #3
0
 public function testWrongMultipart()
 {
     $message = new Zend_Mail_Message(array('raw' => "Content-Type: multipart/mixed\r\n\r\ncontent"));
     try {
         $message->getPart(1);
     } catch (Zend_Exception $e) {
         return;
         // ok
     }
     $this->fail('no exception raised while getting part from message without boundary');
 }