Add mail.send (before/after) triggers

This commit is contained in:
Kijin Sung 2016-05-10 15:40:23 +09:00
parent b971ea19ca
commit 4d1ada5f28

View file

@ -534,15 +534,31 @@ class Mail
*/ */
public function send() public function send()
{ {
$output = \ModuleHandler::triggerCall('mail.send', 'before', $this);
if(!$output->toBool())
{
$this->errors[] = $output->getMessage();
return false;
}
try try
{ {
return $this->driver->send($this); $result = $this->driver->send($this);
} }
catch(\Exception $e) catch(\Exception $e)
{ {
$this->errors[] = $e->getMessage(); $this->errors[] = $e->getMessage();
$result = false;
}
$output = \ModuleHandler::triggerCall('mail.send', 'after', $this);
if(!$output->toBool())
{
$this->errors[] = $output->getMessage();
return false; return false;
} }
return $result;
} }
/** /**