mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-26 22:02:13 +09:00
Reorganize mail driver class structure and add SES driver
This commit is contained in:
parent
a12722ad79
commit
0420361349
8 changed files with 189 additions and 90 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue