Skip to content
Permalink
Browse files

Reset Mailer when exceptions are thrown

  • Loading branch information...
berarma committed Jan 20, 2017
1 parent e808d23 commit e1164a7acc208c62b1411bd67f56024a6b94b20b
Showing with 16 additions and 13 deletions.
  1. +16 −13 src/Mailer/Mailer.php
@@ -233,22 +233,25 @@ public function set($key, $value = null)
*/
public function send($action, $args = [], $headers = [])
{
if (!method_exists($this, $action)) {
throw new MissingActionException([
'mailer' => $this->getName() . 'Mailer',
'action' => $action,
]);
}
try {
if (!method_exists($this, $action)) {
throw new MissingActionException([
'mailer' => $this->getName() . 'Mailer',
'action' => $action,
]);
}
$this->_email->setHeaders($headers);
if (!$this->_email->viewBuilder()->template()) {
$this->_email->viewBuilder()->template($action);
}
$this->_email->setHeaders($headers);
if (!$this->_email->viewBuilder()->template()) {
$this->_email->viewBuilder()->template($action);
}
call_user_func_array([$this, $action], $args);
call_user_func_array([$this, $action], $args);
$result = $this->_email->send();
$this->reset();
$result = $this->_email->send();
} finally {
$this->reset();
}
return $result;
}

0 comments on commit e1164a7

Please sign in to comment.
You can’t perform that action at this time.