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(); }
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); }
<?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');
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');
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');