예제 #1
0
 /**
  * Sends email.
  *
  * @param string $action The name of the mailer action to trigger.
  * @param array $args Arguments to pass to the triggered mailer action.
  * @param array $headers Headers to set.
  * @return array
  * @throws \Cake\Mailer\Exception\MissingActionException
  * @throws \BadMethodCallException
  */
 public function send($action, $args = [], $headers = [])
 {
     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);
     }
     call_user_func_array([$this, $action], $args);
     $result = $this->_email->send();
     $this->reset();
     return $result;
 }