powered by nequal
Home » Mail_Mobile » Timeline » 1445

Diffs

Mail_Mobile/trunk/test/Mail_MobileTest.php

@@ -0,0 +1,116 @@
+<?php
+
+require_once 'Mail_Mobile_TestAbstract.php';
+require_once 'Mail/Mobile.php';
+
+
+class Mail_MobileTest extends Mail_Mobile_TestAbstract
+{
+    public function setUp()
+    {
+    }
+
+    public function testInstance()
+    {
+        $this->assertType('Mail_Mobile', new Mail_Mobile('docomo'));
+    }
+
+    public function testGetMessageText()
+    {
+        $data = array(
+            'docomo'   => 'example@docomo.ne.jp',
+            'softbank' => 'example@softbank.ne.jp',
+            'ezweb'    => 'example@ezweb.ne.jp',
+        );
+
+        foreach ($data as $carrier => $address) {
+            $header = array(
+                'To'      => $address,
+                'From'    => 'from@example.com',
+                'Subject' => 'テストデス[({docomo 1})]',
+            );
+            $body = str_repeat('デス[({docomo 2})]', 20);
+
+            $mail_mobile = new Mail_Mobile($carrier);
+            $ret = $mail_mobile
+                    ->setHeader($header)
+                    ->setTXTBody($body);
+
+            $excepted = file_get_contents(dirname(__FILE__).'/data/text-mail-'.$carrier.'.txt');
+            $actual   = $mail_mobile->getMessage();
+            $this->assertEquals($excepted, $actual);
+        }
+    }
+
+    public function testGetMessageHtml()
+    {
+        $data = array(
+            'docomo'   => 'example@docomo.ne.jp',
+            'softbank' => 'example@softbank.ne.jp',
+            'ezweb'    => 'example@ezweb.ne.jp',
+        );
+
+        foreach ($data as $carrier => $address) {
+            $header = array(
+                'To'      => $address,
+                'From'    => 'from@example.com',
+                'Subject' => 'テストデス[({docomo 1})]',
+            );
+            $body = str_repeat('デス[({docomo 2})]', 20);
+
+            $mail_mobile = new Mail_Mobile($carrier);
+            $ret = $mail_mobile
+                    ->setHeader($header)
+                    ->setHTMLBody(dirname(__FILE__).'/data/mail.html', true)
+                    ->addHTMLImage(dirname(__FILE__).'/data/image.gif', 'image/gif', 'image.gif');
+
+            $excepted = file_get_contents(dirname(__FILE__).'/data/html-mail-'.$carrier.'.txt');
+            $actual   = $mail_mobile->getMessage();
+            $this->assertEqualsHtmlmail($excepted, $actual);
+        }
+    }
+
+    public function testEncodingSetting()
+    {
+        $mail_mobile = new Mail_Mobile('docomo');
+
+        $subject = 'あいうえお';
+        $header = array(
+            'To'      => 'example@docomo.ne.jp',
+            'From'    => 'from@example.com',
+            'Subject' => $subject,
+        );
+
+        $expected = '=?Shift-JIS?B?'.base64_encode(mb_convert_encoding($subject, 'sjis', 'utf-8')).'?=';
+        $mail_mobile->setHeader($header);
+        $ret = $mail_mobile->get();
+
+        $this->assertEquals($expected, $ret[0]['Subject']);
+
+
+
+        $encoding = 'UTF-8';
+        $data = array(
+            'docomo'   => 'Shift-JIS',
+            'softbank' => 'UTF-8',
+            'ezweb'    => 'ISO-2022-JP',
+        );
+        foreach ($data as $carrier => $code) {
+            $mail_mobile = new Mail_Mobile($carrier, $encoding);
+
+            $subject = mb_convert_encoding('あいうえお', $encoding, 'UTF-8');
+            $header = array(
+                'To'      => 'to@example.com',
+                'From'    => 'from@example.com',
+                'Subject' => $subject,
+            );
+
+            $subject = mb_convert_encoding('あいうえお', $code, $encoding);
+            $expected = '=?'.$code.'?B?'.base64_encode($subject).'?=';
+            $mail_mobile->setHeader($header);
+            $ret = $mail_mobile->get();
+
+            $this->assertEquals($expected, $ret[0]['Subject']);
+        }
+    }
+}

Mail_Mobile/trunk/test/Mail_Mobile_Mime_EzwebTest.php

@@ -0,0 +1,71 @@
+<?php
+
+require_once 'Mail_Mobile_TestAbstract.php';
+require_once 'Mail/Mobile/Mime/Ezweb.php';
+
+
+class Mail_Mobile_Mime_EzwebTest extends Mail_Mobile_TestAbstract
+{
+    protected $_carrier = 'ezweb';
+    protected $_type = 'jis-email';
+
+
+    public function setUp()
+    {
+        parent::setUp();
+    }
+
+    public function testInstance()
+    {
+        $this->assertType('Mail_Mobile_Mime_Ezweb', new Mail_Mobile_Mime_Ezweb);
+    }
+
+    public function testGetMessageText()
+    {
+        $header = array(
+            'To'      => 'example@ezweb.ne.jp',
+            'From'    => 'from@example.com',
+            'Subject' => 'テストデス[({docomo 1})]',
+        );
+        $body = str_repeat('デス[({docomo 2})]', 20);
+
+        $header['Subject'] = $this->_restoreString($header['Subject'], 'jis', 'utf-8');
+        $header['Subject'] = '=?ISO-2022-JP?B?'.base64_encode($header['Subject']).'?=';
+
+        $body              = $this->_restoreString($body, 'jis', 'utf-8');
+
+        $mime = new Mail_Mobile_Mime_Ezweb;
+        $mime->headers($header);
+        $mime->setTXTBody($body);
+        $message = $mime->getMessage();
+
+        $actual = file_get_contents(dirname(__FILE__).'/data/text-mail-ezweb.txt');
+
+        $this->assertEquals($actual, $message);
+    }
+
+    public function testGetMessageHtml()
+    {
+        $header = array(
+            'To'      => 'example@ezweb.ne.jp',
+            'From'    => 'from@example.com',
+            'Subject' => 'テストデス[({docomo 1})]',
+        );
+        $html = file_get_contents(dirname(__FILE__).'/data/mail.html');
+
+        $header['Subject'] = $this->_restoreString($header['Subject'], 'jis', 'utf-8');
+        $header['Subject'] = '=?ISO-2022-JP?B?'.base64_encode($header['Subject']).'?=';
+
+        $html              = $this->_restoreString($html, 'jis', 'utf-8');
+
+        $mime = new Mail_Mobile_Mime_Ezweb;
+        $mime->headers($header);
+        $mime->setHTMLBody($html);
+        $mime->addHTMLImage(dirname(__FILE__).'/data/image.gif', 'image/gif', 'image.gif');
+        $message = $mime->getMessage();
+
+        $expected = file_get_contents(dirname(__FILE__).'/data/html-mail-ezweb.txt');
+
+        $this->assertEqualsHtmlmail($expected, $message);
+    }
+}

Mail_Mobile/trunk/test/Mail_Mobile_TestAbstract.php

@@ -0,0 +1,51 @@
+<?php
+
+require_once 'Text/Pictogram/Mobile.php';
+
+
+abstract class Mail_Mobile_TestAbstract extends PHPUnit_Framework_TestCase
+{
+    protected $_carrier;
+    protected $_type;
+
+
+    public function setUp()
+    {
+        $this->picto = Text_Pictogram_Mobile::factory($this->_carrier, $this->_type);
+    }
+
+    protected function _restoreString($string, $to, $from)
+    {
+        return $this->picto->restore(mb_convert_encoding($string, $to, $from));
+    }
+
+    public function assertEqualsHtmlmail($expected, $actual)
+    {
+        // boundary と cid は毎回ランダムに設定されるので、固定値に置き換える
+
+        if (preg_match('/boundary="(=_[a-zA-Z0-9]+)"/', $expected, $match1)) {
+            $boundary1 = $match1[1];
+
+            if (preg_match_all('/boundary="(=_[a-zA-Z0-9]+)"/', $actual, $match2)) {
+                $boundary2 = $match2[1];
+
+                foreach ($boundary2 as $value) {
+                    $actual = str_replace($value, $boundary1, $actual);
+                }
+            }
+        }
+
+        if (preg_match('/Content\-ID: <([^>]+)>/', $expected, $match1)) {
+            $cid1 = $match1[1];
+
+            if (preg_match('/Content\-ID: <([^>]+)>/', $actual, $match2)) {
+                $cid2 = $match2[1];
+
+                $actual = str_replace($cid2, $cid1, $actual);
+            }
+        }
+
+
+        $this->assertEquals($expected, $actual);
+    }
+}

Mail_Mobile/trunk/test/prepare.php

@@ -0,0 +1,21 @@
+<?php
+
+mb_language('ja');
+mb_internal_encoding('UTF-8');
+
+if (defined('E_DEPRECATED')) {
+    error_reporting(E_ALL & ~E_DEPRECATED);
+} else {
+    error_reporting(E_ALL);
+}
+
+set_include_path(realpath(dirname(__FILE__) . '/../src') . PATH_SEPARATOR .
+                 realpath(dirname(__FILE__) . '/../vendor/Mail-1.1.14') . PATH_SEPARATOR .
+                 realpath(dirname(__FILE__) . '/../vendor/Mail_Mime-1.5.2') . PATH_SEPARATOR .
+                 realpath(dirname(__FILE__) . '/../vendor/Mail_mimeDecode-1.5.1') . PATH_SEPARATOR .
+                 realpath(dirname(__FILE__) . '/../vendor/Text_Pictogram_Mobile-0.0.2') . PATH_SEPARATOR .
+                 realpath(dirname(__FILE__) . '/../vendor/Mail_Address_MobileJp') . PATH_SEPARATOR .
+                 realpath(dirname(__FILE__) . '/../vendor/qdmail.1.2.6b') . PATH_SEPARATOR .
+                 get_include_path());
+
+require_once 'PHPUnit/Framework.php';

Mail_Mobile/trunk/test/Mail_Mobile_Mime_DocomoTest.php

@@ -0,0 +1,69 @@
+<?php
+
+require_once 'Mail_Mobile_TestAbstract.php';
+require_once 'Mail/Mobile/Mime/Docomo.php';
+
+
+class Mail_Mobile_Mime_DocomoTest extends Mail_Mobile_TestAbstract
+{
+    protected $_carrier = 'docomo';
+    protected $_type = 'sjis';
+
+
+    public function setUp()
+    {
+        parent::setUp();
+    }
+
+    public function testInstance()
+    {
+        $this->assertType('Mail_Mobile_Mime_Docomo', new Mail_Mobile_Mime_Docomo);
+    }
+
+    public function testGetMessageText()
+    {
+        $header = array(
+            'To'      => 'example@docomo.ne.jp',
+            'From'    => 'from@example.com',
+            'Subject' => 'テストデス[({docomo 1})]',
+        );
+        $body = str_repeat('デス[({docomo 2})]', 20);
+
+        $header['Subject'] = $this->_restoreString($header['Subject'], 'sjis', 'utf-8');
+        $header['Subject'] = '=?Shift-JIS?B?'.base64_encode($header['Subject']).'?=';
+
+        $body              = $this->_restoreString($body, 'sjis', 'utf-8');
+
+        $mime = new Mail_Mobile_Mime_Docomo;
+        $mime->headers($header);
+        $mime->setTXTBody($body);
+        $message = $mime->getMessage();
+
+        $actual = file_get_contents(dirname(__FILE__).'/data/text-mail-docomo.txt');
+
+        $this->assertEquals($actual, $message);
+    }
+
+    public function testGetMessageHtml()
+    {
+        $header = array(
+            'To'      => 'example@docomo.ne.jp',
+            'From'    => 'from@example.com',
+            'Subject' => 'テストデス[({docomo 1})]',
+        );
+        $html = file_get_contents(dirname(__FILE__).'/data/mail.html');
+
+        $header['Subject'] = $this->_restoreString($header['Subject'], 'sjis', 'utf-8');
+        $html              = $this->_restoreString($html, 'sjis', 'utf-8');
+
+        $mime = new Mail_Mobile_Mime_Docomo;
+        $mime->headers($header);
+        $mime->setHTMLBody($html);
+        $mime->addHTMLImage(dirname(__FILE__).'/data/image.gif', 'image/gif', 'image.gif');
+        $message = $mime->getMessage();
+
+        $expected = file_get_contents(dirname(__FILE__).'/data/html-mail-docomo.txt');
+
+        $this->assertEqualsHtmlmail($expected, $message);
+    }
+}

Mail_Mobile/trunk/test/data/html-mail-docomo.txt

@@ -0,0 +1,66 @@
+MIME-Version: 1.0
+To: example@docomo.ne.jp
+From: from@example.com
+Subject: =?Shift-JIS?B?g2WDWINnw969+J8=?=
+Content-Type: multipart/mixed;
+	boundary="=_ad65eb9beee0bcbf78f7516ff58878d8"
+
+--=_ad65eb9beee0bcbf78f7516ff58878d8
+Content-Type: multipart/related;
+	boundary="=_ad65eb9beee0bcbf78f7516ff58878d8"
+
+--=_ad65eb9beee0bcbf78f7516ff58878d8
+Content-Type: multipart/alternative;
+	boundary="=_ad65eb9beee0bcbf78f7516ff58878d8"
+
+--=_ad65eb9beee0bcbf78f7516ff58878d8
+Content-Transfer-Encoding: base64
+Content-Type: text/plain; charset="Shift-JIS"
+
+
+--=_ad65eb9beee0bcbf78f7516ff58878d8
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/html; charset="Shift-JIS"
+
+<html>
+<head>
+</head>
+<body>
+<center>
+<font color=3D"#ff0000" size=3D"+1">
+=82=A0=82=A2=82=A4=82=A6=82=A8=C3=DE=BD=F8=A1
+</font><br />
+<img src=3D"cid:0578afc6ac09e528cbb06bbc5b1c59b2%40example.com" />
+</center>
+</body>
+</html>
+--=_ad65eb9beee0bcbf78f7516ff58878d8--
+
+--=_ad65eb9beee0bcbf78f7516ff58878d8
+Content-Transfer-Encoding: base64
+Content-ID: <0578afc6ac09e528cbb06bbc5b1c59b2%40example.com>
+Content-Type: image/gif;
+ name="image.gif";
+
+R0lGODlhUABQAPcAAAAAAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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HpTm7ebhjyhtShB
+xjwSjDqsCh1tDXZKqm3r3P3y0ybdd5gtrkPurQvOmq6ODn9ebUqP63kPy361Gl6NzVxAQAAVUSNR
+DpM/gQMR8pPCDdJBTQUNGlNYcRivZk4bOWb8pQxSRUq3RFpKRqTPSZTjTK58FonYw2wdJ62MSfHm
+RUc6d+rqOYbnyZCXhpYsaomoSqDxkL6U6DPh06VT51QFc9VqVojFunqFUAAAOw==
+--=_ad65eb9beee0bcbf78f7516ff58878d8--
+--=_ad65eb9beee0bcbf78f7516ff58878d8--

Mail_Mobile/trunk/test/data/text-mail-docomo.txt

@@ -0,0 +1,9 @@
+MIME-Version: 1.0
+To: example@docomo.ne.jp
+From: from@example.com
+Subject: =?Shift-JIS?B?g2WDWINnw969+J8=?=
+Content-Transfer-Encoding: base64
+Content-Type: text/plain; charset="Shift-JIS"
+
+w969+KDD3r34oMPevfigw969+KDD3r34oMPevfigw969+KDD3r34oMPevfigw969+KDD3r34oMPe
+vfigw969+KDD3r34oMPevfigw969+KDD3r34oMPevfigw969+KDD3r34oA==
\ ファイルの末尾に改行がありません

Mail_Mobile/trunk/test/data/mail.html

@@ -0,0 +1,8 @@
+<html>
+<body>
+<font color="#ff0000" size="+1">
+あいうえおデス[({docomo 3})]
+</font><br />
+<img src="image.gif" />
+</body>
+</html>
\ ファイルの末尾に改行がありません

Mail_Mobile/trunk/test/data/image.gif

表示できません: バイナリ形式としてマークされたファイルです。
svn:mime-type = application/octet-stream
属性に変更があったパス: Mail_Mobile/trunk/test/data/image.gif
___________________________________________________________________
名前: svn:mime-type
+ application/octet-stream

Mail_Mobile/trunk/test/data/html-mail-softbank.txt

@@ -0,0 +1,64 @@
+MIME-Version: 1.0
+To: example@softbank.ne.jp
+From: from@example.com
+Subject: =?UTF-8?B?44OG44K544OI776D776e77297oGK?=
+Content-Type: multipart/related;
+	boundary="=_406d8b44e7df698e54883f2277742bf2"
+
+--=_406d8b44e7df698e54883f2277742bf2
+Content-Type: multipart/alternative;
+	boundary="=_406d8b44e7df698e54883f2277742bf2"
+
+--=_406d8b44e7df698e54883f2277742bf2
+Content-Transfer-Encoding: base64
+Content-Type: text/plain; charset="UTF-8"
+
+
+--=_406d8b44e7df698e54883f2277742bf2
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/html; charset="UTF-8"
+
+<html>
+<head>
+</head>
+<body>
+<center>
+<font color=3D"#ff0000" size=3D"+1">
+=E3=81=82=E3=81=84=E3=81=86=E3=81=88=E3=81=8A=EF=BE=83=EF=BE=9E=EF=BD=BD=EE=
+=81=8B
+</font><br />
+<img src=3D"cid:e31e75ee94ef5ebaa19cd64566cc12b5%40example.com" />
+</center>
+</body>
+</html>
+--=_406d8b44e7df698e54883f2277742bf2--
+
+--=_406d8b44e7df698e54883f2277742bf2
+Content-Transfer-Encoding: base64
+Content-ID: <e31e75ee94ef5ebaa19cd64566cc12b5%40example.com>
+Content-Type: image/gif;
+ name="image.gif";
+Content-Disposition: inline;
+ filename="image.gif";
+
+R0lGODlhUABQAPcAAAAAAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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ail_Mobile/trunk/test/data/text-mail-softbank.txt

@@ -0,0 +1,12 @@
+MIME-Version: 1.0
+To: example@softbank.ne.jp
+From: from@example.com
+Subject: =?UTF-8?B?44OG44K544OI776D776e77297oGK?=
+Content-Transfer-Encoding: base64
+Content-Type: text/plain; charset="UTF-8"
+
+776D776e77297oGJ776D776e77297oGJ776D776e77297oGJ776D776e77297oGJ776D776e7729
+7oGJ776D776e77297oGJ776D776e77297oGJ776D776e77297oGJ776D776e77297oGJ776D776e
+77297oGJ776D776e77297oGJ776D776e77297oGJ776D776e77297oGJ776D776e77297oGJ776D
+776e77297oGJ776D776e77297oGJ776D776e77297oGJ776D776e77297oGJ776D776e77297oGJ
+776D776e77297oGJ
\ ファイルの末尾に改行がありません

Mail_Mobile/trunk/test/data/html-mail-ezweb.txt

@@ -0,0 +1,63 @@
+MIME-Version: 1.0
+To: example@ezweb.ne.jp
+From: from@example.com
+Subject: =?ISO-2022-JP?B?GyRCJUYlOSVIGyhJQ149GyhCGyRCdUEbKEI=?=
+Content-Type: multipart/mixed;
+	boundary="=_e1d0d80b1720fe84e6c9020c12e12754"
+
+--=_e1d0d80b1720fe84e6c9020c12e12754
+Content-Type: multipart/alternative;
+	boundary="=_e1d0d80b1720fe84e6c9020c12e12754"
+
+--=_e1d0d80b1720fe84e6c9020c12e12754
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset="ISO-2022-JP"
+
+
+--=_e1d0d80b1720fe84e6c9020c12e12754
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/html; charset="ISO-2022-JP"
+
+<html>
+<head>
+</head>
+<body>
+<center>
+<font color=3D"#ff0000" size=3D"+1">
+=1B$B$"$$$&$($*=1B(IC^=3D=1B(B=1B$BuE=1B(B
+</font><br />
+<img src=3D"cid:35c1cede0ff8a90e238591ad431c6b32@%40example.com" />
+</center>
+</body>
+</html>
+--=_e1d0d80b1720fe84e6c9020c12e12754--
+
+--=_e1d0d80b1720fe84e6c9020c12e12754
+Content-Transfer-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
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACwAAAAAUABQAAAC/4yPqcvt
+Dw+YtNqLs968mw6G4ph95ImmlKm27sa+8hzPtspGz+3mesNr+X6LIC6wIhaNqKESwWwiYZFoqlap
+Wo8lyFY4tey+vXAWSC5jGGkZFrBsqy8KuducrNu5dPZeuub1F/IGJzjIUWjogOiBJ8bYSOUYJxko
+okcItaVokxnVSZPwFXq3aVVaNsr5yFPJlHqEZhQL8gTamvjkR5tLtfvp6qsB/HpTm7ebhjyhtShB
+xjwSjDqsCh1tDXZKqm3r3P3y0ybdd5gtrkPurQvOmq6ODn9ebUqP63kPy361Gl6NzVxAQAAVUSNR
+DpM/gQMR8pPCDdJBTQUNGlNYcRivZk4bOWb8pQxSRUq3RFpKRqTPSZTjTK58FonYw2wdJ62MSfHm
+RUc6d+rqOYbnyZCXhpYsaomoSqDxkL6U6DPh06VT51QFc9VqVojFunqFUAAAOw==
+--=_e1d0d80b1720fe84e6c9020c12e12754--

Mail_Mobile/trunk/test/data/text-mail-ezweb.txt

@@ -0,0 +1,8 @@
+MIME-Version: 1.0
+To: example@ezweb.ne.jp
+From: from@example.com
+Subject: =?ISO-2022-JP?B?GyRCJUYlOSVIGyhJQ149GyhCGyRCdUEbKEI=?=
+Content-Transfer-Encoding: 7bit
+Content-Type: text/plain; charset="ISO-2022-JP"
+
+(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B(IC^=(B$BuF(B
\ ファイルの末尾に改行がありません

Mail_Mobile/trunk/test/Mail_Mobile_Mime_SoftbankTest.php

@@ -0,0 +1,69 @@
+<?php
+
+require_once 'Mail_Mobile_TestAbstract.php';
+require_once 'Mail/Mobile/Mime/Softbank.php';
+
+
+class Mail_Mobile_Mime_SoftbankTest extends Mail_Mobile_TestAbstract
+{
+    protected $_carrier = 'softbank';
+    protected $_type = 'utf-8';
+
+
+    public function setUp()
+    {
+        parent::setUp();
+    }
+
+    public function testInstance()
+    {
+        $this->assertType('Mail_Mobile_Mime_Softbank', new Mail_Mobile_Mime_Softbank);
+    }
+
+    public function testGetMessageText()
+    {
+        $header = array(
+            'To'      => 'example@softbank.ne.jp',
+            'From'    => 'from@example.com',
+            'Subject' => 'テストデス[({docomo 1})]',
+        );
+        $body = str_repeat('デス[({docomo 2})]', 20);
+
+        $header['Subject'] = $this->_restoreString($header['Subject'], 'utf-8', 'utf-8');
+        $header['Subject'] = '=?UTF-8?B?'.base64_encode($header['Subject']).'?=';
+
+        $body              = $this->_restoreString($body, 'utf-8', 'utf-8');
+
+        $mime = new Mail_Mobile_Mime_Softbank;
+        $mime->headers($header);
+        $mime->setTXTBody($body);
+        $message = $mime->getMessage();
+
+        $actual = file_get_contents(dirname(__FILE__).'/data/text-mail-softbank.txt');
+
+        $this->assertEquals($actual, $message);
+    }
+
+    public function testGetMessageHtml()
+    {
+        $header = array(
+            'To'      => 'example@softbank.ne.jp',
+            'From'    => 'from@example.com',
+            'Subject' => 'テストデス[({docomo 1})]',
+        );
+        $html = file_get_contents(dirname(__FILE__).'/data/mail.html');
+
+        $header['Subject'] = $this->_restoreString($header['Subject'], 'utf-8', 'utf-8');
+        $html              = $this->_restoreString($html, 'utf-8', 'utf-8');
+
+        $mime = new Mail_Mobile_Mime_Softbank;
+        $mime->headers($header);
+        $mime->setHTMLBody($html);
+        $mime->addHTMLImage(dirname(__FILE__).'/data/image.gif', 'image/gif', 'image.gif');
+        $message = $mime->getMessage();
+
+        $expected = file_get_contents(dirname(__FILE__).'/data/html-mail-softbank.txt');
+
+        $this->assertEqualsHtmlmail($expected, $message);
+    }
+}

Mail_Mobile/trunk/src/Mail/Mobile/Mime/MimeAbstract.php

@@ -0,0 +1,173 @@
+<?php
+
+require_once 'Mail/mime.php';
+
+
+abstract class Mail_Mobile_Mime_MimeAbstract extends Mail_mime
+{
+    function __construct($crlf = "\r\n")
+    {
+        parent::Mail_mime($crlf);
+    }
+
+    public function addHTMLImage($file, $c_type='application/octet-stream',
+                                 $name = '', $isfile = true)
+    {
+        $ret = parent::addHTMLImage($file, $c_type, $name, $isfile);
+        if (PEAR::isError($ret)) {
+            return $ret;
+        }
+
+        // CID㏑
+        $image =& $this->_html_images[count($this->_html_images) -1];
+        $image['cid'] = $this->_generateContentsID();
+
+        return true;
+    }
+
+    protected function _generateContentsID()
+    {
+        return md5(uniqid(time()));
+    }
+
+    public function &get($build_params = null)
+    {
+        if (isset($build_params)) {
+            while (list($key, $value) = each($build_params)) {
+                $this->_build_params[$key] = $value;
+            }
+        }
+
+        if (isset($this->_headers['From'])){
+            $domain = @strstr($this->_headers['From'],'@');
+            //Bug #11381: Illegal characters in domain ID
+            $domain = str_replace(array("<", ">", "&", "(", ")", " ", "\"", "'"), "", $domain);
+            $domain = urlencode($domain);
+            foreach($this->_html_images as $i => $img){
+                $this->_html_images[$i]['cid'] = $this->_html_images[$i]['cid'] . $domain;
+            }
+        }
+
+        if (count($this->_html_images) AND isset($this->_htmlbody)) {
+            foreach ($this->_html_images as $key => $value) {
+                $regex   = array();
+                $regex[] = '#(\s)((?i)src|background|href(?-i))\s*=\s*(["\']?)' .
+                            preg_quote($value['name'], '#') . '\3#';
+                $regex[] = '#(?i)url(?-i)\(\s*(["\']?)' .
+                            preg_quote($value['name'], '#') . '\1\s*\)#';
+
+                $rep   = array();
+                $rep[] = '\1\2=\3cid:' . $value['cid'] .'\3';
+                $rep[] = 'url(\1cid:' . $value['cid'] . '\2)';
+
+                $this->_htmlbody = preg_replace($regex, $rep, $this->_htmlbody);
+                $this->_html_images[$key]['name'] =
+                    basename($this->_html_images[$key]['name']);
+            }
+        }
+
+        $null        = null;
+        $attachments = count($this->_parts)                 ? true : false;
+        $html_images = count($this->_html_images)           ? true : false;
+        $html        = strlen($this->_htmlbody)             ? true : false;
+        $text        = (!$html AND strlen($this->_txtbody)) ? true : false;
+
+        $message =& $this->_build($null, $attachments, $html_images, $html, $text);
+
+        if (isset($message)) {
+            $output = $message->encode();
+
+            $this->_headers = array_merge($this->_headers,
+                                          $output['headers']);
+            $body = $output['body'];
+            return $body;
+
+        } else {
+            $ret = false;
+            return $ret;
+        }
+    }
+
+    protected function &_build($null, $attachments, $html_images, $html, $text)
+    {
+        switch (true) {
+        case $text AND !$attachments:
+            $message =& $this->_addTextPart($null, $this->_txtbody);
+            break;
+
+        case !$text AND !$html AND $attachments:
+            $message =& $this->_addMixedPart();
+            for ($i = 0; $i < count($this->_parts); $i++) {
+                $this->_addAttachmentPart($message, $this->_parts[$i]);
+            }
+            break;
+
+        case $text AND $attachments:
+            $message =& $this->_addMixedPart();
+            $this->_addTextPart($message, $this->_txtbody);
+            for ($i = 0; $i < count($this->_parts); $i++) {
+                $this->_addAttachmentPart($message, $this->_parts[$i]);
+            }
+            break;
+
+        case $html AND !$attachments AND !$html_images:
+            if (isset($this->_txtbody)) {
+                $message =& $this->_addAlternativePart($null);
+                $this->_addTextPart($message, $this->_txtbody);
+                $this->_addHtmlPart($message);
+            } else {
+                $message =& $this->_addHtmlPart($null);
+            }
+            break;
+
+        case $html AND !$attachments AND $html_images:
+            $message =& $this->_addRelatedPart($null);
+            if (isset($this->_txtbody)) {
+                $alt =& $this->_addAlternativePart($message);
+                $this->_addTextPart($alt, $this->_txtbody);
+                $this->_addHtmlPart($alt);
+            } else {
+                $this->_addHtmlPart($message);
+            }
+            for ($i = 0; $i < count($this->_html_images); $i++) {
+                $this->_addHtmlImagePart($message, $this->_html_images[$i]);
+            }
+            break;
+
+        case $html AND $attachments AND !$html_images:
+            $message =& $this->_addMixedPart();
+            if (isset($this->_txtbody)) {
+                $alt =& $this->_addAlternativePart($message);
+                $this->_addTextPart($alt, $this->_txtbody);
+                $this->_addHtmlPart($alt);
+            } else {
+                $this->_addHtmlPart($message);
+            }
+            for ($i = 0; $i < count($this->_parts); $i++) {
+                $this->_addAttachmentPart($message, $this->_parts[$i]);
+            }
+            break;
+
+        case $html AND $attachments AND $html_images:
+            $message =& $this->_addMixedPart();
+            if (isset($this->_txtbody)) {
+                $alt =& $this->_addAlternativePart($message);
+                $this->_addTextPart($alt, $this->_txtbody);
+                $rel =& $this->_addRelatedPart($alt);
+            } else {
+                $rel =& $this->_addRelatedPart($message);
+            }
+            $this->_addHtmlPart($rel);
+            for ($i = 0; $i < count($this->_html_images); $i++) {
+                $this->_addHtmlImagePart($rel, $this->_html_images[$i]);
+            }
+            for ($i = 0; $i < count($this->_parts); $i++) {
+                $this->_addAttachmentPart($message, $this->_parts[$i]);
+            }
+            break;
+
+        }
+
+        return $message;
+    }
+}

Mail_Mobile/trunk/src/Mail/Mobile/Mime/Ezweb.php

@@ -0,0 +1,62 @@
+<?php
+
+require_once 'Mail/Mobile/Mime/MimeAbstract.php';
+
+
+class Mail_Mobile_Mime_Ezweb extends Mail_Mobile_Mime_MimeAbstract
+{
+    function __construct($crlf = "\r\n")
+    {
+        parent::__construct($crlf);
+
+        $this->_build_params = array_merge(
+            $this->_build_params,
+            array(
+                'head_encoding' => 'base64',
+                'text_encoding' => '7bit',
+                'html_encoding' => 'quoted-printable',
+                '7bit_wrap'     => 998,
+                'html_charset'  => 'ISO-2022-JP',
+                'text_charset'  => 'ISO-2022-JP',
+                'head_charset'  => 'ISO-2022-JP',
+                'ignore-iconv'  => true,
+            )
+        );
+    }
+
+    protected function _generateContentsID()
+    {
+        return md5(uniqid(time())).'@';
+    }
+
+    protected function _build($null, $attachments, $html_images, $html, $text)
+    {
+        switch (true) {
+            // デコメール本文とインライン画像
+        case $html AND !$attachments AND $html_images:
+            /**
+             * multipart/mixed
+             * |- multipart/alternative
+             * |  |- text/plain
+             * |  \- text/html
+             * \- image/**
+             */
+            $message =& $this->_addMixedPart($null);
+
+            $alt =& $this->_addAlternativePart($message);
+            $this->_addTextPart($alt, isset($this->_txtbody) ? $this->_txtbody : '');
+            $this->_addHtmlPart($alt);
+
+            for ($i = 0; $i < count($this->_html_images); $i++) {
+                $this->_addHtmlImagePart($message, $this->_html_images[$i]);
+            }
+            break;
+
+        default:
+            $message = parent::_build($null, $attachments, $html_images, $html, $text);
+            break;
+        }
+
+        return $message;
+    }
+}

Mail_Mobile/trunk/src/Mail/Mobile/Mime/Docomo.php

@@ -0,0 +1,72 @@
+<?php
+
+require_once 'Mail/Mobile/Mime/MimeAbstract.php';
+
+
+class Mail_Mobile_Mime_Docomo extends Mail_Mobile_Mime_MimeAbstract
+{
+    function __construct($crlf = "\r\n")
+    {
+        parent::__construct($crlf);
+
+        $this->_build_params = array_merge(
+            $this->_build_params,
+            array(
+                'head_encoding' => 'base64',
+                'text_encoding' => 'base64',
+                'html_encoding' => 'quoted-printable',
+                '7bit_wrap'     => 998,
+                'html_charset'  => 'Shift-JIS',
+                'text_charset'  => 'Shift-JIS',
+                'head_charset'  => 'Shift-JIS',
+                'ignore-iconv'  => true,
+            )
+        );
+    }
+
+    protected function &_build($null, $attachments, $html_images, $html, $text)
+    {
+        switch (true) {
+            // デコメール本文とインライン画像
+        case $html AND !$attachments AND $html_images:
+            /**
+             * multipart/mixed
+             * \- multipart/related
+             *    |- multipart/alternative
+             *    |  |- text/plain
+             *    |  \- text/html
+             *    \--image/xxx (*n)
+             */
+            $message =& $this->_addMixedPart();
+
+            $rel =& $this->_addRelatedPart($message);
+
+            $alt =& $this->_addAlternativePart($rel);
+            $this->_addTextPart($alt, isset($this->_txtbody) ? $this->_txtbody : '');
+            $this->_addHtmlPart($alt);
+
+            for ($i = 0; $i < count($this->_html_images); $i++) {
+                $this->_addHtmlImagePart($rel, $this->_html_images[$i]);
+            }
+            break;
+
+        default:
+            $message = parent::_build($null, $attachments, $html_images, $html, $text);
+        }
+
+        return $message;
+    }
+
+    function &_addHtmlImagePart(&$obj, $value)
+    {
+        $params = array(
+            'content_type' => $value['c_type'],
+            'encoding'     => 'base64',
+            'dfilename'    => $value['name'],
+            'cid'          => $value['cid'],
+        );
+
+        $ret = $obj->addSubpart($value['body'], $params);
+        return $ret;
+    }
+}

Mail_Mobile/trunk/src/Mail/Mobile/Mime/Softbank.php

@@ -0,0 +1,56 @@
+<?php
+
+require_once 'Mail/Mobile/Mime/MimeAbstract.php';
+
+
+class Mail_Mobile_Mime_Softbank extends Mail_Mobile_Mime_MimeAbstract
+{
+    function __construct($crlf = "\r\n")
+    {
+        parent::__construct($crlf);
+
+        $this->_build_params = array_merge(
+            $this->_build_params,
+            array(
+                'head_encoding' => 'base64',
+                'text_encoding' => 'base64',
+                'html_encoding' => 'quoted-printable',
+                '7bit_wrap'     => 998,
+                'html_charset'  => 'UTF-8',
+                'text_charset'  => 'UTF-8',
+                'head_charset'  => 'UTF-8',
+            )
+        );
+    }
+
+    protected function _build($null, $attachments, $html_images, $html, $text)
+    {
+        switch (true) {
+            // デコメール本文とインライン画像
+        case $html AND !$attachments AND $html_images:
+            /**
+             * multipart/related
+             * |- multipart/alternative
+             * |  |- text/plain
+             * |  \- text/html
+             * \- image/**
+             */
+            $message =& $this->_addRelatedPart($null);
+
+            $alt =& $this->_addAlternativePart($message);
+            $this->_addTextPart($alt, isset($this->_txtbody) ? $this->_txtbody : '');
+            $this->_addHtmlPart($alt);
+
+            for ($i = 0; $i < count($this->_html_images); $i++) {
+                $this->_addHtmlImagePart($message, $this->_html_images[$i]);
+            }
+            break;
+
+        default:
+            $message = parent::_build($null, $attachments, $html_images, $html, $text);
+            break;
+        }
+
+        return $message;
+    }
+}

Mail_Mobile/trunk/src/Mail/Mobile.php

@@ -0,0 +1,138 @@
+<?php
+
+require_once 'Mail.php';
+require_once 'Mail/mime.php';
+require_once 'Text/Pictogram/Mobile.php';
+
+
+class Mail_Mobile
+{
+    private static $_type = array(
+        'docomo' => array(
+            'emoji_type'    => 'sjis',
+            'charset'       => 'Shift-JIS',
+            'mime_charset'  => 'Shift-JIS',
+        ),
+        'softbank' => array(
+            'emoji_type'    => 'utf-8',
+            'charset'       => 'UTF-8',
+            'mime_charset'  => 'UTF-8',
+         ),
+        'ezweb' => array(
+            'emoji_type'    => 'jis-email',
+            'charset'       => 'jis',
+            'mime_charset'  => 'ISO-2022-JP',
+         ),
+    );
+
+    private $_carrier;
+
+    private $_picto;
+
+    private $_mime;
+
+    private $_encoding;
+
+
+    function __construct($carrier, $encoding = null)
+    {
+        $this->_carrier = $carrier;
+
+
+        $this->_mime = self::loadMime($carrier);
+
+        $type = self::$_type[$this->_carrier];
+        $this->_picto = Text_Pictogram_Mobile::factory($this->_carrier, $type['emoji_type']);
+
+        if (is_null($encoding)) {
+            $this->_encoding = mb_internal_encoding();
+        } else {
+            $this->_encoding = $encoding;
+        }
+    }
+
+    public static function loadMime($carrier)
+    {
+        $class = 'Mail_Mobile_Mime_'.ucfirst(strtolower($carrier));
+        if (!class_exists($class)) {
+            $file = str_replace('_', '/', $class).'.php';
+            require_once $file;
+        }
+
+        return new $class("\r\n");
+    }
+
+    public function setHeader($header)
+    {
+        $charset      = self::$_type[$this->_carrier]['charset'];
+        $mime_charset = self::$_type[$this->_carrier]['mime_charset'];
+
+
+        if (isset($header['Subject'])) {
+            $subject = $header['Subject'];
+            $subject = $this->_restoreString($subject);
+            $subject = "=?".$mime_charset."?B?" . base64_encode($subject) . "?=";
+            $header['Subject'] = $subject;
+        }
+        $this->_mime->headers($header);
+
+        return $this;
+    }
+
+    public function setTXTBody($data, $isfile = false, $append = false)
+    {
+        if ($isfile) {
+            $content = file_get_contents($data);
+        } else {
+            $content = $data;
+        }
+        $content = $this->_restoreString($content);
+
+        $this->_mime->setTXTBody($content, false, $append);
+
+        return $this;
+    }
+
+    public function setHTMLBody($data, $isfile = false, $append = false)
+    {
+        if ($isfile) {
+            $content = file_get_contents($data);
+        } else {
+            $content = $data;
+        }
+        $content = $this->_restoreString($content);
+
+        $this->_mime->setHTMLBody($content, false, $append);
+
+        return $this;
+    }
+
+    public function addHTMLImage($file, $c_type='application/octet-stream',
+                                 $name = '', $isfile = true)
+    {
+        $this->_mime->addHTMLImage($file, $c_type, $name, $isfile);
+
+        return $this;
+    }
+
+    public function get()
+    {
+        $body   = $this->_mime->get();
+        $header = $this->_mime->headers();
+
+        return array($header, $body);
+    }
+
+    public function getMessage()
+    {
+        return $this->_mime->getMessage();
+    }
+
+    private function _restoreString($content)
+    {
+        $content = mb_convert_encoding($content, self::$_type[$this->_carrier]['charset'], $this->_encoding);
+        $content = $this->_picto->restore($content);
+
+        return $content;
+    }
+}