/** * @inheritDoc */ public function send($action, $args = [], $headers = []) { $this->fixateLocale(); $result = parent::send($action, $args, $headers); $this->restoreLocale(); return $result; }
/** * Wrap the original send to catch erros and log them. * * @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. * @throws \Cake\Mailer\Exception\MissingActionException * @throws \BadMethodCallException * @return array */ public function send($action, $args = [], $headers = []) { $results = []; try { $results = parent::send($action, $args, $headers); } catch (\Exception $e) { Log::write(LOG_CRIT, 'Emails cannot be sent: ' . $e->getMessage(), $this->_email); } return $results; }