powered by nequal
Home » jpSimpleMailPlugin » Timeline » 2181

Changeset 2181 -- 2010-10-13 13:01:04

Comment
[Package Release] jpSimpleMailPlugin

Diffs

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/unit/jpPHPMailerTest.php

@@ -0,0 +1,70 @@
+<?php
+include(dirname(__FILE__) . '/../bootstrap/unit.php');
+$t = new lime_test(23, new lime_output_color());
+// send mail
+$t->diag('check method');
+$mailer = jpSimpleMail::create('PHPMailer');
+$t->isa_ok($mailer, 'jpPHPMailer', 'created instance is correct');
+// charset
+$old = $mailer->getCharset();
+$mailer->setCharset('utf-8');
+$t->is($mailer->getCharset(), 'utf-8', 'test Charset');
+$mailer->setCharset($old);
+// priority
+$old = $mailer->getPriority();
+$mailer->setPriority('1');
+$t->is($mailer->getPriority(), '1', 'test Priority');
+$mailer->setPriority($old);
+// encoding
+$old = $mailer->getEncoding();
+$mailer->setEncoding('7bit');
+$t->is($mailer->getEncoding(), '7bit', 'test Encoding');
+$mailer->setPriority($old);
+// return path
+$old = $mailer->getReturnPath();
+$mailer->setReturnPath($params['from']);
+$t->is($mailer->getReturnPath(), $params['from'], 'test Return Path');
+$mailer->setReturnPath($old);
+// addTo
+$t->is($mailer->addTo($_SERVER['SF_TEST_TO_ADDRESS']), null, 'test to call addTo method');
+$t->is($mailer->addTo($_SERVER['SF_TEST_TO_ADDRESS'], $params['to_name']), null, 'test to call addTo method with name');
+// from
+$old = $mailer->getFrom();
+$mailer->setFrom($params['from'], $params['from_name']);
+$t->is($mailer->getFrom(), $params['from'], 'test From');
+$mailer->setFrom($old);
+//addCc
+$t->is($mailer->addCc($_SERVER['SF_TEST_TO_ADDRESS']), null, 'test to call addCc method');
+$t->is($mailer->addCc($_SERVER['SF_TEST_TO_ADDRESS'], $params['to_name']), null, 'test to call addCc method with name');
+//addBcc
+$t->is($mailer->addBcc($_SERVER['SF_TEST_TO_ADDRESS']), null, 'test to call addBcc method');
+$t->is($mailer->addBcc($_SERVER['SF_TEST_TO_ADDRESS'], $params['to_name']), null, 'test to call addBcc method with name');
+// Subject
+$old = $mailer->getSubject();
+$mailer->setSubject($params['subject']);
+$t->is($mailer->getSubject(), $params['subject'], 'test Subject');
+$mailer->setSubject($old);
+// body
+$old = $mailer->getBody();
+$mailer->setBody($params['body']);
+$t->is($mailer->getbody(), $params['body'], 'test body');
+$mailer->setBody($old);
+//addReplyTo
+$t->is($mailer->addReplyTo($params['from']), null, 'test to call addReplyTo method');
+$t->is($mailer->addReplyTo($params['from'], $params['from_name']), null, 'test to call addReplyTo method with name');
+// clearTo
+$t->is($mailer->clearTo(), null, 'test to call clearTo method');
+// clearCc
+$t->is($mailer->clearCc(), null, 'test to call clearCc method');
+// clearBcc
+$t->is($mailer->clearBcc(), null, 'test to call clearBcc method');
+// clearReplyTo
+$t->is($mailer->clearReplyTo(), null, 'test to call clearReplyTo method');
+// sender ( only this class)
+$old = $mailer->getSender();
+$mailer->setSender($params['from'], $params['from_name']);
+$t->is($mailer->getSender(), $params['from'], 'test Sender');
+$mailer->setSender($old);
+// addAddress (only this class)
+$t->is($mailer->addAddress($_SERVER['SF_TEST_TO_ADDRESS']), null, 'test to call addAddress method');
+$t->is($mailer->addAddress($_SERVER['SF_TEST_TO_ADDRESS'], $params['to_name']), null, 'test to call addAddress method with name');
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/unit/jpPHPMailerTest.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/unit/jpSwiftMailerTest.php

@@ -0,0 +1,70 @@
+<?php
+include(dirname(__FILE__) . '/../bootstrap/unit.php');
+$t = new lime_test(23, new lime_output_color());
+// send mail
+$t->diag('check method');
+$mailer = jpSimpleMail::create('SwiftMailer');
+$t->isa_ok($mailer, 'jpSwiftMailer', 'created instance is correct');
+// charset
+$old = $mailer->getCharset();
+$mailer->setCharset('utf-8');
+$t->is($mailer->getCharset(), 'utf-8', 'test Charset');
+$mailer->setCharset($old);
+// priority
+$old = $mailer->getPriority();
+$mailer->setPriority('1');
+$t->is($mailer->getPriority(), '1', 'test Priority');
+$mailer->setPriority($old);
+// encoding
+$old = $mailer->getEncoding();
+$mailer->setEncoding('7bit');
+$t->is($mailer->getEncoding(), '7bit', 'test Encoding');
+$mailer->setPriority($old);
+// return path
+$old = $mailer->getReturnPath();
+$mailer->setReturnPath($params['from']);
+$t->is($mailer->getReturnPath(), $params['from'], 'test Return Path');
+$mailer->setReturnPath($old);
+// addTo
+$t->is($mailer->addTo($_SERVER['SF_TEST_TO_ADDRESS']), null, 'test to call addTo method');
+$t->is($mailer->addTo($_SERVER['SF_TEST_TO_ADDRESS'], $params['to_name']), null, 'test to call addTo method with name');
+// from
+$old = $mailer->getFrom();
+$mailer->setFrom($params['from'], $params['from_name']);
+$t->is($mailer->getFrom(), $params['from'], 'test From');
+$mailer->setFrom($old);
+//addCc
+$t->is($mailer->addCc($_SERVER['SF_TEST_TO_ADDRESS']), null, 'test to call addCc method');
+$t->is($mailer->addCc($_SERVER['SF_TEST_TO_ADDRESS'], $params['to_name']), null, 'test to call addCc method with name');
+//addBcc
+$t->is($mailer->addBcc($_SERVER['SF_TEST_TO_ADDRESS']), null, 'test to call addBcc method');
+$t->is($mailer->addBcc($_SERVER['SF_TEST_TO_ADDRESS'], $params['to_name']), null, 'test to call addBcc method with name');
+// Subject
+$old = $mailer->getSubject();
+$mailer->setSubject($params['subject']);
+$t->is($mailer->getSubject(), $params['subject'], 'test Subject');
+$mailer->setSubject($old);
+// body
+$old = $mailer->getBody();
+$mailer->setBody($params['body']);
+$t->is($mailer->getbody(), $params['body'], 'test body');
+$mailer->setBody($old);
+//addReplyTo
+$t->is($mailer->addReplyTo($params['from']), null, 'test to call addReplyTo method');
+$t->is($mailer->addReplyTo($params['from'], $params['from_name']), null, 'test to call addReplyTo method with name');
+// clearTo
+$t->is($mailer->clearTo(), null, 'test to call clearTo method');
+// clearCc
+$t->is($mailer->clearCc(), null, 'test to call clearCc method');
+// clearBcc
+$t->is($mailer->clearBcc(), null, 'test to call clearBcc method');
+// clearReplyTo
+$t->is($mailer->clearReplyTo(), null, 'test to call clearReplyTo method');
+// sender ( only this class)
+$old = $mailer->getSender();
+$mailer->setSender($params['from'], $params['from_name']);
+$t->is($mailer->getSender(), $params['from'], 'test Sender');
+$mailer->setSender($old);
+// addAddress (only this class)
+$t->is($mailer->addAddress($_SERVER['SF_TEST_TO_ADDRESS']), null, 'test to call addAddress method');
+$t->is($mailer->addAddress($_SERVER['SF_TEST_TO_ADDRESS'], $params['to_name']), null, 'test to call addAddress method with name');
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/unit/jpSwiftMailerTest.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/unit/jpQdmailTest.php

@@ -0,0 +1,70 @@
+<?php
+include(dirname(__FILE__) . '/../bootstrap/unit.php');
+$t = new lime_test(23, new lime_output_color());
+// send mail
+$t->diag('check method');
+$mailer = jpSimpleMail::create('Qdmail');
+$t->isa_ok($mailer, 'jpQdmail', 'created instance is correct');
+// charset
+$old = $mailer->getCharset();
+$mailer->setCharset('utf-8');
+$t->is($mailer->getCharset(), 'utf-8', 'test Charset');
+$mailer->setCharset($old);
+// priority
+$old = $mailer->getPriority();
+$mailer->setPriority('1');
+$t->is($mailer->getPriority(), '1', 'test Priority');
+$mailer->setPriority($old);
+// encoding
+$old = $mailer->getEncoding();
+$mailer->setEncoding('7bit');
+$t->is($mailer->getEncoding(), '7bit', 'test Encoding');
+$mailer->setPriority($old);
+// return path
+$old = $mailer->getReturnPath();
+$mailer->setReturnPath($params['from']);
+$t->is($mailer->getReturnPath(), $params['from'], 'test Return Path');
+$mailer->setReturnPath($old);
+// addTo
+$t->is($mailer->addTo($_SERVER['SF_TEST_TO_ADDRESS']), null, 'test to call addTo method');
+$t->is($mailer->addTo($_SERVER['SF_TEST_TO_ADDRESS'], $params['to_name']), null, 'test to call addTo method with name');
+// from
+$old = $mailer->getFrom();
+$mailer->setFrom($params['from'], $params['from_name']);
+$t->is($mailer->getFrom(), $params['from'], 'test From');
+$mailer->setFrom($old);
+//addCc
+$t->is($mailer->addCc($_SERVER['SF_TEST_TO_ADDRESS']), null, 'test to call addCc method');
+$t->is($mailer->addCc($_SERVER['SF_TEST_TO_ADDRESS'], $params['to_name']), null, 'test to call addCc method with name');
+//addBcc
+$t->is($mailer->addBcc($_SERVER['SF_TEST_TO_ADDRESS']), null, 'test to call addBcc method');
+$t->is($mailer->addBcc($_SERVER['SF_TEST_TO_ADDRESS'], $params['to_name']), null, 'test to call addBcc method with name');
+// Subject
+$old = $mailer->getSubject();
+$mailer->setSubject($params['subject']);
+$t->is($mailer->getSubject(), $params['subject'], 'test encoded Subject');
+$mailer->setSubject($old);
+// body
+$old = $mailer->getBody();
+$mailer->setBody($params['body']);
+$t->is($mailer->getbody(), $params['body'], 'test body');
+$mailer->setBody($old);
+//addReplyTo
+$t->is($mailer->addReplyTo($params['from']), null, 'test to call addReplyTo method');
+$t->is($mailer->addReplyTo($params['from'], $params['from_name']), null, 'test to call addReplyTo method with name');
+// clearTo
+$t->is($mailer->clearTo(), null, 'test to call clearTo method');
+// clearCc
+$t->is($mailer->clearCc(), null, 'test to call clearCc method');
+// clearBcc
+$t->is($mailer->clearBcc(), null, 'test to call clearBcc method');
+// clearReplyTo
+$t->is($mailer->clearReplyTo(), null, 'test to call clearReplyTo method');
+// sender ( only this class)
+$old = $mailer->getSender();
+$mailer->setSender($params['from'], $params['from_name']);
+$t->is($mailer->getSender(), $params['from'], 'test Sender');
+$mailer->setSender($old);
+// addAddress (only this class)
+$t->is($mailer->addAddress($_SERVER['SF_TEST_TO_ADDRESS']), null, 'test to call addAddress method');
+$t->is($mailer->addAddress($_SERVER['SF_TEST_TO_ADDRESS'], $params['to_name']), null, 'test to call addAddress method with name');
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/unit/jpQdmailTest.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/functional/jpPHPMailerTest.php

@@ -0,0 +1,32 @@
+<?php
+include(dirname(__FILE__) . '/../bootstrap/functional.php');
+$t = new lime_test(2, new lime_output_color());
+$t->diag('send mail by PHPMailer');
+// success to send a mail
+$process = true;
+try{
+    $mailer = jpSimpleMail::create('PHPMailer');
+    $mailer->setSubject($params['subject']);
+    $mailer->setSender($_SERVER['SF_TEST_TO_ADDRESS']);
+    $mailer->addTo(sprintf('%s <%s>', $params['to_name'], $_SERVER['SF_TEST_TO_ADDRESS']));
+    $mailer->setFrom(sprintf('%s <%s>', $params['from_name'], $params['from']));
+    $mailer->setBody($params['body']);
+    $mailer->send();
+} catch (jpSendMailException $e) {
+  $process = false;
+}
+$t->is($process, true, 'succeess to send mail');
+// fail to send a mail
+$proccess = true;
+try{
+    $mailer = jpSimpleMail::create('PHPMailer');
+    $mailer->setSubject($params['subject']);
+    $mailer->setSender($_SERVER['SF_TEST_TO_ADDRESS']);
+//    $mailer->addTo(sprintf('%s <%s>', $params['to_name'], $_SERVER['SF_TEST_TO_ADDRESS']));
+    $mailer->setFrom(sprintf('%s <%s>', $params['from_name'], $params['from']));
+    $mailer->setBody($params['body']);
+    $mailer->send();
+} catch (jpSendMailException $e) {
+  $proccess = false;
+}
+$t->is($proccess, false, 'catch the jpSendMailException');
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/functional/jpPHPMailerTest.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/functional/jpSwiftMailerTest.php

@@ -0,0 +1,32 @@
+<?php
+include(dirname(__FILE__) . '/../bootstrap/functional.php');
+$t = new lime_test(2, new lime_output_color());
+$t->diag('send mail by Swift Mailer');
+// success to send a mail
+$process = true;
+try {
+    $mailer = jpSimpleMail::create('SwiftMailer');
+    $mailer->setSubject($params['subject']);
+    $mailer->setSender($_SERVER['SF_TEST_TO_ADDRESS']);
+    $mailer->addTo(sprintf('%s <%s>', $params['to_name'], $_SERVER['SF_TEST_TO_ADDRESS']));
+    $mailer->setFrom(sprintf('%s <%s>', $params['to_name'], $params['from']));
+    $mailer->setBody($params['body']);
+    $mailer->send();
+} catch (jpSendMailException $e) {
+  $process = false;
+}
+$t->is($process, true, 'succeess to send mail');
+// fail to send a mail
+$proccess = true;
+try{
+    $mailer = jpSimpleMail::create('SwiftMailer');
+    $mailer->setSubject($params['subject']);
+    $mailer->setSender($_SERVER['SF_TEST_TO_ADDRESS']);
+//    $mailer->addTo(sprintf('%s <%s>', $params['to_name'], $_SERVER['SF_TEST_TO_ADDRESS']));
+    $mailer->setFrom(sprintf('%s <%s>', $params['from_name'], $params['from']));
+    $mailer->setBody($params['body']);
+    $mailer->send();
+} catch (jpSendMailException $e) {
+  $proccess = false;
+}
+$t->is($proccess, false, 'catch the jpSendMailException');
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/functional/jpSwiftMailerTest.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/functional/jpQdmailTest.php

@@ -0,0 +1,32 @@
+<?php
+include(dirname(__FILE__) . '/../bootstrap/functional.php');
+$t = new lime_test(2, new lime_output_color());
+$t->diag('send mail by Qdmail');
+// success to send a mail
+$process = true;
+try {
+    $mailer = jpSimpleMail::create('Qdmail');
+    $mailer->setSubject($params['subject']);
+    $mailer->setSender($_SERVER['SF_TEST_TO_ADDRESS']);
+    $mailer->addTo(sprintf('%s <%s>', $params['to_name'], $_SERVER['SF_TEST_TO_ADDRESS']));
+    $mailer->setFrom(sprintf('%s <%s>', $params['to_name'], $params['from']));
+    $mailer->setBody($params['body']);
+    $mailer->send();
+} catch (jpSendMailException $e) {
+  $process = false;
+}
+$t->is($process, true, 'succeess to send mail');
+// fail to send a mail
+$proccess = true;
+try{
+    $mailer = jpSimpleMail::create('Qdmail');
+    $mailer->setSubject($params['subject']);
+    $mailer->setSender($_SERVER['SF_TEST_TO_ADDRESS']);
+//    $mailer->addTo(sprintf('%s <%s>', $params['to_name'], $_SERVER['SF_TEST_TO_ADDRESS']));
+    $mailer->setFrom(sprintf('%s <%s>', $params['from_name'], $params['from']));
+    $mailer->setBody($params['body']);
+    $mailer->send();
+} catch (jpSendMailException $e) {
+  $proccess = false;
+}
+$t->is($proccess, false, 'catch the jpSendMailException');
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/functional/jpQdmailTest.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/bin/prove.php

@@ -0,0 +1,9 @@
+<?php
+include dirname(__FILE__).'/../bootstrap/unit.php';
+
+$h = new lime_harness(new lime_output_color());
+$h->register(sfFinder::type('file')->name('*Test.php')->in(dirname(__FILE__).'/..'));
+
+exit($h->run() ? 0 : 1);
+
+
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/bin/prove.php
___________________________________________________________________
追加: svn:executable
+ *
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/bootstrap/unit.php

@@ -0,0 +1,35 @@
+<?php
+if (!isset($_SERVER['SYMFONY']))
+{
+  throw new RuntimeException('Could not find symfony core libraries.');
+}
+if (!isset($_SERVER['SF_TEST_TO_ADDRESS']))
+{
+  throw new RuntimeException('Could not find "SF_TEST_TO_ADDRESS".');
+}
+require_once $_SERVER['SYMFONY'].'/autoload/sfCoreAutoload.class.php';
+sfCoreAutoload::register();
+
+$configuration = new sfProjectConfiguration(getcwd());
+require_once $configuration->getSymfonyLibDir().'/vendor/lime/lime.php';
+
+require_once dirname(__FILE__).'/../../config/jpSimpleMailPluginConfiguration.class.php';
+$plugin_configuration = new jpSimpleMailPluginConfiguration($configuration, dirname(__FILE__).'/../..');
+
+// set ini
+mb_internal_encoding('utf-8');
+// test params
+$params = array(
+                'subject' => "長いサブジェクトです長いサブジェクトです長いサブジェクトです長いサブジェクトです長いサブジェクトです長いサブジェクトです長いサブジェクトです長いサブジェクトです",
+                'body' => "本文です。テストです。",
+                'from' => 'from@example.com',
+                'from_name' => '送信元',
+                'to_name' => '送信先',
+                'return_path' => 'return_path@example.com',
+                'reply_to' => 'reply_to@example.com',
+                );
+//encoded_value
+$params['encoded_subject'] = mb_encode_mimeheader($params['subject'], 'iso-2022-jp', 'B', "\n");
+$params['encoded_from_name'] = mb_encode_mimeheader($params['from_name'], 'iso-2022-jp', 'B', "\n");
+$params['encoded_to_name'] = mb_encode_mimeheader($params['to_name'], 'iso-2022-jp', 'B', "\n");
+$params['encoded_body'] = mb_convert_encoding($params['body'], 'iso-2022-jp', mb_internal_encoding());
\ No newline at end of file
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/bootstrap/unit.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/bootstrap/functional.php

@@ -0,0 +1,37 @@
+<?php
+if (!isset($_SERVER['SYMFONY']))
+{
+  throw new RuntimeException('Could not find symfony core libraries.');
+}
+if (!isset($_SERVER['SF_TEST_TO_ADDRESS']))
+{
+  throw new RuntimeException('Could not find "SF_TEST_TO_ADDRESS".');
+}
+
+if (!isset($app))
+{
+  $app = 'frontend';
+}
+
+require_once $_SERVER['SYMFONY'].'/autoload/sfCoreAutoload.class.php';
+sfCoreAutoload::register();
+
+// this functional test is as same as unit test.
+$configuration = new sfProjectConfiguration(getcwd());
+require_once $configuration->getSymfonyLibDir().'/vendor/lime/lime.php';
+
+require_once dirname(__FILE__).'/../../config/jpSimpleMailPluginConfiguration.class.php';
+$plugin_configuration = new jpSimpleMailPluginConfiguration($configuration, dirname(__FILE__).'/../..');
+
+// set ini
+mb_internal_encoding('utf-8');
+// test params
+$params = array(
+                'subject' => "長いサブジェクトです長いサブジェクトです長いサブジェクトです長いサブジェクトです長いサブジェクトです長いサブジェクトです長いサブジェクトです長いサブジェクトです",
+                'body' => "本文です。テストです。",
+                'from' => 'from@example.com',
+                'from_name' => '送信元',
+                'to_name' => '送信先',
+                'return_path' => 'return_path@example.com',
+                'reply_to' => 'reply_to@example.com',
+                );
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/test/bootstrap/functional.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/LICENCE


jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/config/jpSimpleMailPluginConfiguration.class.php

@@ -0,0 +1,19 @@
+<?php
+
+/**
+ * jpSimpleMailPlugin configuration.
+ *
+ * @package     jpSimpleMailPlugin
+ * @subpackage  config
+ * @author      Your name here
+ * @version     SVN: $Id$
+ */
+class jpSimpleMailPluginConfiguration extends sfPluginConfiguration
+{
+  /**
+   * @see sfPluginConfiguration
+   */
+  public function initialize()
+  {
+  }
+}
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/config/jpSimpleMailPluginConfiguration.class.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/jpSimpleMail.class.php

@@ -0,0 +1,63 @@
+<?php
+/**
+ * jpSimpleMail class for create the instance of the mailer library
+ *
+ * @package    jpSimpleMailPlugin
+ * @subpackage jpSimpleMail
+ * @author     brt.river <brt.river@gmail.com>
+ * @version    $Id$
+ */
+class jpSimpleMail
+{
+  /**
+   * Factory method
+   *
+   * @param string $mailer: the name of the instance
+   *                        'PHPMailer', 'SwiftMailer', 'Qdmail' for default
+   *
+   * @return object $class: the created instance
+   */
+  public static function create($mailer)
+  {
+    $class = sprintf("jp%s", $mailer);
+    return new $class;
+  }
+  /**
+   * Filter the values
+   *
+   * @param string $value: the value before
+   *
+   * @return string the value after
+   */
+  public static function filter($value)
+  {
+    return str_replace("\x00", "", trim($value));
+  }
+  /**
+   * Convert encoding and filter value
+   *
+   * @param string $value : the value before
+   *
+   * @return string the value after
+   */
+  public static function mb_encode_mimeheader($value)
+  {
+    $value = self::filter($value);
+    return mb_encode_mimeheader($value, 'iso-2022-jp', 'B', "\n");
+  }
+  /**
+   * Divide an address into the name part and the address part.
+   *
+   * @param string $address: the address
+   *
+   * @return array array('the address part', 'the name part')
+   */
+  public static function splitAddress($address)
+  {
+    if (preg_match('/^(.+)\s<(.+?)>$/', $address, $matches)) {
+      return array($matches[2], $matches[1]);
+    } else {
+      return array($address, '');
+    }
+  }
+}
\ No newline at end of file
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/jpSimpleMail.class.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL
追加: svn:mergeinfo

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/kzl_Jp_Swift_Mime_Headers_UnstructredHeader.php

@@ -0,0 +1,34 @@
+<?php
+//@require 'Swift/Mime/Headers/AbstractHeader.php';
+//@require 'Swift/Mime/HeaderEncoder.php';
+
+/**
+ * 日本語(ISO-2022-JP)用メールヘッダクラス
+ * @package kzlJpSwiftMailerPlugin
+ * @subpackage Mime
+ * @author kawaguchi
+ * @url http://www.kuzilla.co.jp/
+ */
+class kzl_Jp_Swift_Mime_Headers_UnstructuredHeader
+  extends Swift_Mime_Headers_UnstructuredHeader
+{
+  // override
+  public function getFieldBody()
+  {
+    if (!$this->getCachedValue())
+    {
+      // ISO-2022-JP対応
+      if (strcasecmp($this->getCharset(), 'iso-2022-jp') === 0)
+      {
+        // TODO:: エンコードを内包するパターンでSubjectがMIMEエンコードされているのを確認
+        // subjectをセットする際にエンコードするのでここでは何もしない
+        //$this->setCachedValue($this->getValue());
+        // エンコード内包する場合。(本来はこちらが正しいかも)
+        $this->setCachedValue(jpSimpleMail::mb_encode_mimeheader(( $this->getValue())));
+      } else {
+        parent::getFieldBody();
+      }
+    }
+    return $this->getCachedValue();
+  }
+}
\ No newline at end of file

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/mailer/jpPHPMailer.class.php

@@ -0,0 +1,166 @@
+<?php
+/**
+ * jpPHPMailer class
+ *
+ * @package    jpSimpleMailPlugin
+ * @subpackage lib
+ * @author     brt.river <brt.river@gmail.com>
+ * @version    $Id$
+ */
+class jpPHPMailer extends jpMailer
+{
+  public function initialize()
+  {
+    $this->setMailer(new PHPMailer);
+    mb_language('Ja');
+    $this->setCharset('iso-2022-jp');
+    $this->setEncoding('7bit');
+  }
+  public function setCharset($charset)
+  {
+    $this->mailer->CharSet = $charset;
+  }
+  public function getCharset()
+  {
+    return $this->mailer->CharSet;
+  }
+  public function setPriority($priority)
+  {
+    $this->mailer->Priority = $priority;
+  }
+  public function getPriority()
+  {
+    return $this->mailer->Priority;
+  }
+  public function setEncoding($encoding)
+  {
+    $this->mailer->Encoding = $encoding;
+  }
+  public function getEncoding()
+  {
+    return $this->mailer->Encoding;
+  }
+  public function setSender($address, $name = null)
+  {
+    if (!$address) {
+      return;
+    }
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $this->setReturnPath($address);
+  }
+  public function getSender()
+  {
+    return $this->getReturnPath();
+  }
+  public function setReturnPath($address)
+  {
+    $this->mailer->Sender = $address;
+  }
+  public function getReturnPath()
+  {
+    return $this->mailer->Sender;
+  }
+  public function addAddress($address, $name = null)
+  {
+    $this->addTo($address, $name);
+  }
+  public function addTo($address, $name = null)
+  {
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->mailer->AddAddress($address, $name);
+  }
+  public function setFrom($address, $name = null)
+  {
+    if (!$address) {
+      return;
+    }
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $this->mailer->From     = $address;
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->mailer->FromName = $name;
+  }
+  public function addCc($address, $name = null)
+  {
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->mailer->AddCc($address, $name);
+  }
+  public function addBcc($address, $name = null)
+  {
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->mailer->AddBcc($address, $name);
+  }
+  public function setSubject($subject)
+  {
+    $subject = jpSimpleMail::mb_encode_mimeheader($subject);
+    $this->mailer->Subject = $subject;
+  }
+  public function setBody($body)
+  {
+    $body = mb_convert_encoding($body, $this->getCharset(), mb_internal_encoding());
+    $this->mailer->Body = $body;
+  }
+  public function setAltBody($body)
+  {
+    $body = mb_convert_encoding($body, $this->getCharset(), mb_internal_encoding());
+    $this->mailer->setAltBody($body);
+  }
+  public function addReplyTo($address, $name = null)
+  {
+    if (!$address) {
+      return;
+    }
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->mailer->AddReplyTo($address, $name);
+  }
+  public function getFrom()
+  {
+    return $this->mailer->From;
+  }
+  public function getSubject()
+  {
+    return mb_decode_mimeheader($this->mailer->Subject);
+  }
+  public function getBody()
+  {
+    return mb_convert_encoding($this->mailer->Body, mb_internal_encoding(), $this->getCharset());
+  }
+  public function clearTo()
+  {
+    $this->mailer->ClearAddresses();
+  }
+  public function clearCcs()
+  {
+    $this->mailer->ClearCcs();
+  }
+  public function clearBccs()
+  {
+    $this->mailer->ClearBccs();
+  }
+  public function clearReplyTo()
+  {
+    $this->mailer->ClearReplyTos();
+  }
+  public function send()
+  {
+    if (!$this->mailer->Send()) {
+      throw new jpSendMailException($this->mailer->ErrorInfo);
+    }
+    return true;
+  }
+}
\ No newline at end of file
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/mailer/jpPHPMailer.class.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/mailer/jpSwiftMailer.class.php

@@ -0,0 +1,214 @@
+<?php
+/**
+ * jpSwiftMailer class
+ *
+ * @package    jpSimpleMailPlugin
+ * @subpackage lib
+ * @author     brt.river <brt.river@gmail.com>
+ * @version    $Id$
+ */
+class jpSwiftMailer extends jpMailer
+{
+  public
+    $address = "",
+    $message = "",
+    $from = "";
+  public function initialize()
+  {
+    $this->setMailer(new Swift(new Swift_Connection_NativeMail()));
+    mb_language('Ja');
+    $this->message = new Swift_Message();
+    $this->message->setHeaders(new Swift_Message_jpHeaders());
+    $this->message->setContentType('text/plain');
+    $this->setCharset('iso-2022-jp');
+    $this->setEncoding('7bit');
+    $this->address = new Swift_RecipientList();
+  }
+  public function setCharset($charset)
+  {
+    $this->message->setCharset($charset);
+  }
+  public function getCharset()
+  {
+    return $this->message->getCharset();
+  }
+  public function setPriority($priority)
+  {
+    $this->message->setPriority($priority);
+  }
+  public function getPriority()
+  {
+    return $this->message->getPriority();
+  }
+  public function setEncoding($encoding)
+  {
+    $this->message->setEncoding($encoding);
+  }
+  public function getEncoding()
+  {
+    return $this->message->getEncoding();
+  }
+  public function setSender($address, $name = null)
+  {
+    if (!$address) {
+      return;
+    }
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $this->message->setReturnPath($address);
+  }
+  public function getSender()
+  {
+    return $this->message->getReturnPath();
+  }
+  public function setReturnPath($address)
+  {
+    $this->message->setReturnPath($address);
+  }
+  public function getReturnPath()
+  {
+    return $this->message->getReturnPath();
+  }
+  public function addAddress($address, $name = null)
+  {
+    $this->addTo($address, $name);
+  }
+  public function addTo($address, $name = null)
+  {
+    if ($name == null)
+    {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->address->addTo($address, $name);
+  }
+  public function setFrom($address, $name = null)
+  {
+    if (!$address) {
+      return;
+    }
+    if ($name == null)
+    {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $this->mailer->From     = $address;
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->from = new Swift_Address($address, $name);
+  }
+  public function addCc($address, $name = null)
+  {
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->address->addCc($address, $name);
+  }
+  public function addBcc($address, $name = null)
+  {
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->address->addBcc($address, $name);
+  }
+  public function setSubject($subject)
+  {
+    $this->message->setSubject($subject);
+  }
+  public function setBody($body)
+  {
+    $body = mb_convert_encoding($body, $this->getCharset(), mb_internal_encoding());
+    $this->message->setBody($body);
+  }
+  public function setAltBody($body)
+  {
+  }
+  public function addReplyTo($address, $name = null)
+  {
+    if (!$address) {
+      return;
+    }
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->message->setReplyTo(array($address => $name));
+  }
+  public function getFrom()
+  {
+    if (! $this->from instanceof Swift_Address) return "";
+    return $this->from->getAddress();
+  }
+  public function getSubject()
+  {
+    return $this->message->getSubject();
+  }
+  public function getBody()
+  {
+    return mb_convert_encoding($this->message->getBody(), mb_internal_encoding(), $this->getCharset());
+  }
+  public function clearTo()
+  {
+    $this->address->flushTo();
+  }
+  public function clearCcs()
+  {
+    $this->address->flushCc();
+  }
+  public function clearBccs()
+  {
+    $this->address->flushBcc();
+  }
+  public function clearReplyTo()
+  {
+    $this->message->setReplyTo('');
+  }
+  public function send()
+  {
+    try {
+      $this->mailer->send($this->message, $this->address, $this->from);
+      $this->mailer->disconnect();
+      return true;
+    } catch ( Exception $e) {
+      $this->mailer->disconnect();
+      throw new jpSendMailException($e);
+    }
+  }
+}
+
+/**
+ * Swift_Message_jpHeader class
+ *
+ * Custmize Swift_Message_Header class for iso-2022-jp
+ *
+ * @package    jpSimpleMailPlugin
+ * @subpackage lib
+ * @author     brt.river <brt.river@gmail.com>
+ * @version    $Id$
+ */
+class Swift_Message_jpHeaders extends Swift_Message_Headers
+{
+  public function __construct()
+  {
+    $this->setCharset('iso-2022-jp');
+  }
+  public function getEncoded($name)
+  {
+    //      return parent::getEncoded($name);
+    if ($this->getCharset() == 'iso-2022-jp' && (strtolower($name) == "subject")) {
+      $encoded_value = (array)$this->get($name);
+      foreach ($encoded_value as $key => $value ) {
+        $encoded_value[$key] = mb_encode_mimeheader($value, $this->getCharset(), 'B', "\n");
+      }
+      //If there are multiple values in this header, put them on separate lines, cleared by commas
+      $lname = strtolower($name);
+      //Append attributes if there are any
+      $this->cached[$lname] = implode("," . $this->LE . " ", $encoded_value);
+      if (!empty($this->attributes[$lname])) $this->cached[$lname] .= $this->buildAttributes($this->cached[$lname], $lname);
+      return $this->cached[$lname];
+    } else {
+      return parent::getEncoded($name);
+    }
+  }
+}
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/mailer/jpSwiftMailer.class.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/mailer/jpQdmail.class.php

@@ -0,0 +1,134 @@
+<?php
+/**
+ * jpQdmail class
+ *
+ * @package    jpSimpleMailPlugin
+ * @subpackage lib
+ * @author     brt.river <brt.river@gmail.com>
+ * @version    $Id$
+ */
+class jpQdmail extends jpMailer
+{
+  public function initialize()
+  {
+    $this->setMailer(new sfQdmail);
+    mb_language('Ja');
+  }
+  public function setCharset($charset)
+  {
+    $this->mailer->setCharset($charset);
+  }
+  public function getCharset()
+  {
+    return $this->mailer->getCharset();
+  }
+  public function setPriority($priority)
+  {
+    $this->mailer->setPriority($priority);
+  }
+  public function getPriority()
+  {
+    return $this->mailer->getPriority();
+  }
+  public function setEncoding($encoding)
+  {
+    $this->mailer->setEncoding($encoding);
+  }
+  public function getEncoding()
+  {
+    return $this->mailer->getEncoding();
+  }
+  public function setSender($address, $name = null)
+  {
+    return $this->mailer->setSender($address, $name);
+  }
+  public function getSender()
+  {
+    return $this->getReturnPath();
+  }
+  public function setReturnPath($address)
+  {
+    $this->mailer->setSender($address);
+  }
+  public function getReturnPath()
+  {
+    return $this->mailer->getSender();
+  }
+  public function addAddress($address, $name = null)
+  {
+    $this->addTo($address, $name);
+  }
+  public function addTo($address, $name = null)
+  {
+    $this->mailer->addAddress($address, $name);
+  }
+  public function setFrom($address, $name = null)
+  {
+    $this->mailer->setFrom($address, $name);
+  }
+  public function addCc($address, $name = null)
+  {
+    $this->mailer->AddCc($address, $name);
+  }
+  public function addBcc($address, $name = null)
+  {
+    $this->mailer->AddBcc($address, $name);
+  }
+  public function setSubject($subject)
+  {
+    $this->mailer->setSubject($subject);
+  }
+  public function setBody($body)
+  {
+    $this->mailer->setBody($body);
+  }
+  public function setAltBody($body)
+  {
+    $this->mailer->setAltBody($body);
+  }
+  public function addReplyTo($address, $name = null)
+  {
+    $this->mailer->AddReplyTo($address, $name);
+  }
+  public function getTo()
+  {
+    return $this->mailer->getSender();
+  }
+  public function getFrom()
+  {
+    // if not set, email validation erro is occured.
+    return $this->mailer->from[0]['mail'];
+  }
+  public function getSubject()
+  {
+    $arr = $this->mailer->getSubject();
+    return (isset($arr['CONTENT']))? $arr['CONTENT'] : "";
+  }
+  public function getBody()
+  {
+    return $this->mailer->getBody();
+  }
+  public function cleararTo()
+  {
+    $this->mailer->ClearAddresses();
+  }
+  public function clearCcs()
+  {
+    $this->mailer->ClearCcs();
+  }
+  public function clearBccs()
+  {
+    $this->mailer->ClearBccs();
+  }
+  public function clearReplyTo()
+  {
+    $this->mailer->ClearReplyTos();
+  }
+  public function send()
+  {
+    if (!$this->mailer->send()) {
+      throw new jpSendMailException('error in send email');
+    }
+    return true;
+  }
+}
\ No newline at end of file
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/mailer/jpQdmail.class.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/mailer/jpMailer.class.php

@@ -0,0 +1,84 @@
+<?php
+/**
+ * jpMailer abstruct class
+ *
+ * jpMailer class is an abstruct class which you can create a warpper class for an each Mail Library.
+ *
+ * @package    jpSimpleMailPlugin
+ * @subpackage lib
+ * @author     brt.river <brt.river@gmail.com>
+ * @version    $Id$
+ */
+abstract class jpMailer
+{
+  public
+    $mailer = null;
+  public function __construct()
+  {
+    $this->initialize();
+  }
+  public function initialize()
+  {}
+  public function setMailer($mailer)
+  {
+    $this->mailer = $mailer;
+  }
+  public function getMailer()
+  {
+    return $this->mailer;
+  }
+  public function setCharset($charset)
+  {}
+  public function getCharset()
+  {}
+  public function setContetType($type)
+  {}
+  public function setPriority($priority)
+  {}
+  public function getPriority()
+  {}
+  public function setEncoding($encoding)
+  {}
+  public function getEncoding()
+  {}
+  public function setReturnPath($address)
+  {}
+  public function getReturnPath()
+  {}
+  public function addTo($address, $name = null)
+  {}
+  public function setFrom($address, $name = null)
+  {}
+  public function addCc($address, $name = null)
+  {}
+  public function addBcc($address, $name = null)
+  {}
+  public function setSubject($subject)
+  {}
+  public function setBody($body)
+  {}
+  public function addReplyTo($reply_to)
+  {}
+  public function getFrom()
+  {}
+  public function getSubject()
+  {}
+  public function getBody()
+  {}
+  public function getReplyTo()
+  {}
+  public function clearTo()
+  {}
+  public function clearCc()
+  {}
+  public function clearBcc()
+  {}
+  public function clearReplyTo()
+  {}
+  public function send()
+  {}
+  public function __call($name, $args)
+  {
+    throw new sfException(sprintf('%s is undefiend method in %s class', $name, get_class($this)));
+  }
+}
\ No newline at end of file
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/mailer/jpMailer.class.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/mailer/jpSwiftMailer4.class.php

@@ -0,0 +1,182 @@
+<?php
+/**
+ * jpSwiftMailer4 class
+ *
+ *  this class is for SwiftMailer ver4
+ *  require kzl_Jp_Swift_Mime_Headers_UnstructuredHeader
+ *    ref: http://www.kuzilla.co.jp/article.php/20100301symfony
+ *
+ * @package    jpSimpleMailPlugin
+ * @subpackage lib
+ * @author     brt.river <brt.river@gmail.com>
+ * @version    $Id: jpSwiftMailer4.class.php 1725 2010-03-22 13:32:49Z brtriver $
+ */
+require_once dirname(dirname(__FILE__)) . "/kzl_Jp_Swift_Mime_Headers_UnstructredHeader.php";
+class jpSwiftMailer4 extends jpMailer
+{
+  public
+    $address = "",
+    $message = "",
+    $from = "";
+  public function initialize()
+  {
+    $this->setMailer(sfContext::getInstance()->getMailer());
+    mb_language('Ja');
+    $this->message = Swift_Message::newInstance();
+    $this->message->getHeaders()->remove('Subject');
+    $subjectHeader = new kzl_Jp_Swift_Mime_Headers_UnstructuredHeader('Subject',
+      new Swift_Mime_HeaderEncoder_Base64HeaderEncoder());
+    $this->message->getHeaders()->set($subjectHeader);
+    $this->message->setContentType('text/plain');
+    $this->setCharset('iso-2022-jp');
+    $this->message->setEncoder(Swift_Encoding::get7BitEncoding());
+  }
+  public function setCharset($charset)
+  {
+    $this->message->setCharset($charset);
+  }
+  public function getCharset()
+  {
+    return $this->message->getCharset();
+  }
+  public function setPriority($priority)
+  {
+    $this->message->setPriority($priority);
+  }
+  public function getPriority()
+  {
+    return $this->message->getPriority();
+  }
+  public function setEncoding($encoding)
+  {
+    $this->message->setEncoding($encoding);
+  }
+  public function getEncoding()
+  {
+    return $this->message->getEncoding();
+  }
+  public function setSender($address, $name = null)
+  {
+    if (!$address) {
+      return;
+    }
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $this->message->setReturnPath($address);
+  }
+  public function getSender()
+  {
+    return $this->message->getReturnPath();
+  }
+  public function setReturnPath($address)
+  {
+    $this->message->setReturnPath($address);
+  }
+  public function getReturnPath()
+  {
+    return $this->message->getReturnPath();
+  }
+  public function addAddress($address, $name = null)
+  {
+    $this->message->addTo($address, $name);
+  }
+  public function addTo($address, $name = null)
+  {
+    if ($name == null)
+    {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->message->addTo($address, $name);
+  }
+  public function setFrom($address, $name = null)
+  {
+    if (!$address) {
+      return;
+    }
+    if ($name == null)
+    {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $this->mailer->From     = $address;
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->message->setFrom($address, $name);
+  }
+  public function addCc($address, $name = null)
+  {
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->message->addCc($address, $name);
+  }
+  public function addBcc($address, $name = null)
+  {
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->message->addBcc($address, $name);
+  }
+  public function setSubject($subject)
+  {
+    $this->message->setSubject($subject);
+  }
+  public function setBody($body)
+  {
+    $body = mb_convert_encoding($body, $this->getCharset(), mb_internal_encoding());
+    $this->message->setBody($body);
+  }
+  public function setAltBody($body)
+  {
+  }
+  public function addReplyTo($address, $name = null)
+  {
+    if (!$address) {
+      return;
+    }
+    if ($name == null) {
+      list($address, $name) = jpSimpleMail::splitAddress($address);
+    }
+    $name = jpSimpleMail::mb_encode_mimeheader($name);
+    $this->message->setReplyTo($address, $name);
+  }
+  public function getFrom()
+  {
+    return $this->from->getAddress();
+  }
+  public function getSubject()
+  {
+    return $this->message->getSubject();
+  }
+  public function getBody()
+  {
+    return mb_convert_encoding($this->message->getBody(), mb_internal_encoding(), $this->getCharset());
+  }
+  public function clearTo()
+  {
+    $this->message->setTo(null);
+  }
+  public function clearCcs()
+  {
+    $this->message->setCc(null);
+  }
+  public function clearBccs()
+  {
+    $this->message->setBcc(null);
+  }
+  public function clearReplyTo()
+  {
+    $this->message->setReplyTo(null);
+  }
+  public function send()
+  {
+    try {
+      $this->mailer->send($this->message);
+      return true;
+    } catch ( Exception $e) {
+      throw new jpSendMailException($e);
+    }
+  }
+}

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/exception/jpSendMailException.class.php

@@ -0,0 +1,12 @@
+<?php
+/**
+ * jpSendMailException class
+ *
+ * @package    jpSimpleMailPlugin
+ * @subpackage exception
+ * @author     brt.river <brt.river@gmail.com>
+ * @version    $Id$
+ */
+class jpSendMailException extends sfException
+{
+}
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/lib/exception/jpSendMailException.class.php
___________________________________________________________________
追加: svn:keywords
+ Id Date Revision Author HeadURL

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/notes.txt

@@ -0,0 +1,11 @@
+Version 0.2.0
+--------------------------------------------------
+
+add: a new mailer class for SwiftMailer ver4.
+     This class requires kzl_Jp_Swift_Mime_Headers_UnstructuredHeader class.
+     ref: http://www.kuzilla.co.jp/article.php/20100301symfony
+
+Version 0.1.0
+--------------------------------------------------
+
+First Release.
\ No newline at end of file
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/notes.txt
___________________________________________________________________
追加: svn:mergeinfo

jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/desc.txt

@@ -0,0 +1,163 @@
+====== jpSimpleMailPlugin ======
+
+このプラグインは日本語(iso-2022-jp)による簡単なメール送信をライブラリに依存せず共通のインターフェースで送信するためのプラグインです。
+
+===== 概要 =====
+
+PHPMailer, Swift Mailer, Qdmailが読み込まれてさえすれば以下の共通のインターフェースで日本語(iso-2022-jp)によるメール送信を行います。
+引数で与えた日本語文字列はプラグインによって内部エンコーディングからJISに変換されます。
+
+<code php>
+$mailer = jpSimpleMail::create('SwiftMailer'); // このサンプルではSwift Mailerを利用しています。
+$mailer->setSubject('メール送信テストです');
+$mailer->setSender('from@example.com');
+$mailer->addTo(sprintf('%s <%s>', '宛先 太郎', 'to@example.com'));
+$mailer->setFrom(sprintf('%s <%s>', '管理者', 'from@example.com'));
+$mailer->setBody('本文です');
+$rs = $mailer->send();
+</code>
+
+また、smtpでの会話には対応していません。
+既に公開してあるjpMailPluginとは全くの別モノになります。
+
+
+===== 対応しているメール送信ライブラリ =====
+以下のライブラリにてテストを行っています。
+
+^ライブラリ名^バージョン^
+|[[http://phpmailer.codeworxtech.com/|PHPMailer]]|v2.3|
+|[[http://swiftmailer.org/|Swift Mailer]]|3.3.3, 4.0.6|
+|[[http://hal456.net/qdmail/|Qdmailに用意されているsfQdmail]]|1.2.6b|
+
+※Qdmailを利用される場合は環境によって、Strictエラー、Noticeのエラーが発生する場合があります。
+※symfony1.3以降ではSwiftMailer4が標準でバンドルされています。
+===== 基本的な利用 =====
+まず、PHPMailer, Swift Mailer, Qdmailのどれかをダウンロードし、autoloadに登録するかincludeしておきます。
+symfony1.3以降ではSwiftMailer4がバンドルされているのでSwift Mailerをダウンロードする必要はありません。
+ただし、iso-2022-jpでエンコードするためにkzl_Jp_Swift_Mime_Headers_UnstructuredHeaderクラスが必要になります。
+最新版では[[http://www.kuzilla.co.jp/|kuzilla]]さんのご好意により本プラグインに最低限必要なクラスを同梱していますので別途ライブラリを用意する必要はありません。
+また、kuzillaさんのサイトで日本語対応のメール用デバッグパネルも用意されたプラグインもあるので活用してみてください。
+[[http://www.kuzilla.co.jp/article.php/20100301symfony]]
+
+あとは、jpMail::createメソッドの引数にメーラーを指定し、以下のように呼び出します。
+
+(例)PHPMailerで送信するサンプル
+<code php>
+    $mailer = jpSimpleMail::create('PHPMailer');
+    $mailer->setSubject('メール送信テストです');
+    $mailer->setSender('from@example.com');
+    $mailer->addTo(sprintf('%s <%s>', '宛先 太郎', 'to@example.com'));
+    $mailer->setFrom(sprintf('%s <%s>', '管理者', 'from@example.com'));
+    $mailer->setBody('本文です');
+    $rs = $mailer->send();
+</code>
+
+createメソッドで渡す事ができる名前は以下の3つです。
+`PHPMailer`, `SwiftMailer`, `Qdmail`, `SwiftMailer4`
+symfony1.3以降ではSwiftMailer4を利用することになるはずです。
+
+===== メール本文を動的に作成する =====
+
+symfony1.0まではsfMailというクラスが用意されており、このクラスを利用することでアクションの結果をメールの本文(body)に適用することができました。しかしsymfony1.1以降はこのクラスは廃止されてしまいましたが、もっと簡単に動的に本文を作成するための方法が用意されました。
+
+それはコンポーネント(またはパーシャル)の処理結果を変数で受け取る事ができるようになったのです。
+
+例えば、以下のようなgetComponentメソッドを使います。
+
+  * apps/frontend/modules/sendmail/actions/actions.class.php
+<code php>
+  public function executeIndex(sfWebRequest $request)
+  {
+    $mailer = jpSimpleMail::create('SwiftMailer');
+    $mailer->setSubject('メール送信テストです');
+    $mailer->setSender('master@example.com');
+    $mailer->addTo(sprintf('%s <%s>', 'シンフォニー 太郎', 'symfony@example.com'));
+    $mailer->setFrom(sprintf('%s <%s>', '管理者', 'master@example.com'));
+    // getComponentでsendmailモジュールのcreateMailBodyコンポーネントに値(name)を渡しつつ処理結果をsetBodyする
+    $mailer->setBody($this->getComponent('sendmail', 'createMailBody', array('name' => 'なまえ')));
+    $rs = $mailer->send();
+</code>
+
+  * apps/frontend/modules/sendmail/actions/components.class.php
+<code php>
+<?php
+class sendmailComponents extends sfComponents
+{
+  public function executeCreateMailBody($request)
+  {
+    // ここで本文を作成するのに必要なロジックをコーディングする
+    $this->url = "http://www.example.com/";
+  }
+}
+</code>
+
+テンプレートではアサインした$nameと$urlを利用可能
+  * apps/frontend/modules/sendmail/templates/_createMailBody.php
+<code php>
+<?php echo $name ?>
+
+------------------
+テストです。
+どうでしょうか?
+
+<?php echo $url ?>
+
+-----
+</code>
+
+===== 高度な利用 =====
+上記サンプルのような利用方法ではなく、HTMLメールや添付メールなど各ライブラリを直接操作したい場合は直接各ライブラリを呼び出して利用します。
+その場合は以下のように直接ライブラリのインスタンスを取得することができます。
+
+<code php>
+// getterでインスタンスを取得
+$Mailer = $mailer->getMailer();
+// または直接mailerプロパティを参照
+$Mailer = $mailer->mailer;
+</code>
+
+===== その他のメール送信ライブラリにも対応させたい =====
+
+Zend_Mailなどのその他のメール送信ライブラリにも対応させることも簡単です。
+jpSimpleMailPlugin/lib/mailer/jpXXX.class.phpという名前でjpMailerクラスを基に実装すれば良いだけです。
+
+===== 送信に失敗したとき =====
+各々のメールライブラリで送信した結果がエラーだった場合は、jpSendMailExceptionを投げるようになっています。
+なので以下のようなtry,catchが利用できます。
+<code php>
+try {
+  $mailer = jpSimpleMail::create('Qdmail');
+  ....
+  $mailer->send();
+} catch (jpSendMailException $e) {
+  // エラーの場合の処理
+}
+</code>
+
+また、jpSendMailExceptionはsfExceptionを継承しているだけです。
+
+===== テスト =====
+単体テスト(メソッドレベルのテスト)と機能テスト(実際にメールを送信してみるテスト)も附属のtestディレクトリのファイルを参考にすると簡単に作成できると思います。
+また、テストを実行する場合は $_SERVER['SYMFONY']に使用しているsymfonyのライブラリのパスを設定しなければなりません。そして、テスト送信先のアドレスを$_SERVER['SF_TEST_TO_ADDRESS']に設定しなければなりません。
+bashの場合は以下のように環境変数をセットしておきます。
+
+テストを実行する前にexportで変数をSYMFONYをセットしておく
+<code>
+$ export SYMFONY=/path-to-symfony/lib
+$ export SF_TEST_TO_ADDRESS=to@example.com
+</code>
+
+全てのテストを実行するためにはprove.phpを叩きます。
+<code>
+$ php /path-to-plugin/test/bin/prove.php
+</code>
+
+単体テストではエンコーディングが正しく行われているかではなく、メソッドがエラーなく実装されているかどうかをテストしています。テストとしては不十分かもしれません。。
+
+===== 他のライブラリの依存度 =====
+
+このライブラリはテストするためにsymfonyを活用していますが、ライブラリ自体は最後のメール送信時(sendメソッド)で失敗したときに投げる例外sfExceptionのみsymfonyに依存しています。
+
+なので、フレームワークとは関係なくても各ファイルを読み込みさえできれば移植も簡単(なはず)。
+
+(追記) symfony 1.3以降で標準となったSwiftMailer4対応したため、sfContextインスタンスに依存する部分があります。
\ No newline at end of file
属性に変更があったパス: jpSimpleMailPlugin/tags/release-0.3.0-20101013130103/desc.txt
___________________________________________________________________
追加: svn:mergeinfo