Reorganize mail driver class structure and add SES driver

This commit is contained in:
Kijin Sung 2016-05-06 21:31:04 +09:00
parent a12722ad79
commit 0420361349
8 changed files with 189 additions and 90 deletions

View file

@ -5,18 +5,8 @@ namespace Rhymix\Framework\Drivers\Mail;
/**
* The mail() function mail driver.
*/
class MailFunction implements \Rhymix\Framework\Drivers\MailInterface
class MailFunction extends Base implements \Rhymix\Framework\Drivers\MailInterface
{
/**
* The singleton instance is stored here.
*/
protected static $_instance = null;
/**
* The mailer instance is stored here.
*/
protected $_mailer = null;
/**
* Direct invocation of the constructor is not permitted.
*/
@ -26,18 +16,13 @@ class MailFunction implements \Rhymix\Framework\Drivers\MailInterface
}
/**
* Create a new instance of the current mail driver, using the given settings.
* Get the human-readable name of this mail driver.
*
* @param array $config
* @return void
* @return string
*/
public static function getInstance(array $config)
public static function getName()
{
if (self::$_instance === null)
{
self::$_instance = new self();
}
return self::$_instance;
return 'PHP mail()';
}
/**
@ -62,7 +47,16 @@ class MailFunction implements \Rhymix\Framework\Drivers\MailInterface
*/
public function send(\Rhymix\Framework\Mail $message)
{
$result = $this->mailer->send($message->message, $errors);
try
{
$result = $this->mailer->send($message->message, $errors);
}
catch(\Exception $e)
{
$message->errors[] = $e->getMessage();
return false;
}
foreach ($errors as $error)
{
$message->errors[] = $error;