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