_config['eol'])) { $eol = $this->_config['eol']; } $headers = $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc')); $to = $headers['To']; unset($headers['To']); $headers = $this->_headersToString($headers, $eol); $message = implode($eol, $email->message()); $params = null; if (!ini_get('safe_mode')) { $params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null; } $this->_mail($to, $email->subject(), $message, $headers, $params); return array('headers' => $headers, 'message' => $message); } /** * Wraps internal function mail() and throws exception instead of errors if anything goes wrong * * @param string $to email's recipient * @param string $subject email's subject * @param string $message email's body * @param string $headers email's custom headers * @param string $params additional params for sending email * @throws SocketException if mail could not be sent * @return void */ protected function _mail($to, $subject, $message, $headers, $params = null) { if (!@mail($to, $subject, $message, $headers, $params)) { throw new SocketException(__d('cake_dev', 'Could not send email.')); } } }