charset = $charset; } } /** * Set From * * @param string $email * @param string $name * @return void * @thrown SocketException */ public function setFrom($email, $name = null) { $oldFrom = $this->_from; $this->_setEmail('_from', $email, $name); if (count($this->_from) !== 1) { $this->_from = $oldFrom; throw new SocketException(__('From requires only 1 email address.')); } } /** * Get the From information * * @return array Key is email, Value is name. If Key is equal of Value, the name is not specified */ public function getFrom() { return $this->_from; } /** * Set To * * @param mixed $email String with email, Array with email as key, name as value or email as value (without name) * @param string $name * @return void */ public function setTo($email, $name = null) { $this->_setEmail('_to', $email, $name); } /** * Add To * * @param mixed $email String with email, Array with email as key, name as value or email as value (without name) * @param string $name * @return void */ public function addTo($email, $name = null) { $this->_addEmail('_to', $email, $name); } /** * Get To * * @return array */ public function getTo() { return $this->_to; } /** * Set Cc * * @param mixed $email String with email, Array with email as key, name as value or email as value (without name) * @param string $name * @return void */ public function setCc($email, $name = null) { $this->_setEmail('_cc', $email, $name); } /** * Add Cc * * @param mixed $email String with email, Array with email as key, name as value or email as value (without name) * @param string $name * @return void */ public function addCc($email, $name = null) { $this->_addEmail('_cc', $email, $name); } /** * Get Cc * * @return array */ public function getCc() { return $this->_cc; } /** * Set Bcc * * @param mixed $email String with email, Array with email as key, name as value or email as value (without name) * @param string $name * @return void */ public function setBcc($email, $name = null) { $this->_setEmail('_bcc', $email, $name); } /** * Add Bcc * * @param mixed $email String with email, Array with email as key, name as value or email as value (without name) * @param string $name * @return void */ public function addBcc($email, $name = null) { $this->_addEmail('_bcc', $email, $name); } /** * Get Bcc * * @return array */ public function getBcc() { return $this->_bcc; } /** * Set email * * @param string $varName * @param mixed $email * @param mixed $name * @return void */ protected function _setEmail($varName, $email, $name) { if (!is_array($email)) { if ($name === null) { $this->{$varName} = array($email => $email); } else { $this->{$varName} = array($email => $name); } return; } $list = array(); foreach ($email as $key => $value) { if (is_int($key)) { $list[$value] = $value; } else { $list[$key] = $value; } } $this->{$varName} = $list; } /** * Add email * * @param string $varName * @param mixed $email * @param mixed $name * @return void */ protected function _addEmail($varName, $email, $name) { if (!is_array($email)) { if ($name === null) { $this->{$varName}[$email] = $email; } else { $this->{$varName}[$email] = $name; } return; } $list = array(); foreach ($email as $key => $value) { if (is_int($key)) { $list[$value] = $value; } else { $list[$key] = $value; } } $this->{$varName} = array_merge($this->{$varName}, $list); } /** * Sets headers for the message * * @param array Associative array containing headers to be set. * @return void * @thrown SocketException */ public function setHeaders($headers) { if (!is_array($headers)) { throw new SocketException(__('$headers should be an array.')); } $this->_headers = $headers; } /** * Add header for the message * * @param array $headers * @return void * @thrown SocketException */ public function addHeaders($headers) { if (!is_array($headers)) { throw new SocketException(__('$headers should be an array.')); } $this->_headers = array_merge($this->_headers, $headers); } /** * Get list of headers * * @param boolean $includeToAndCc * @param boolean $includeBcc * @param boolean $includeSubject * @return array */ public function getHeaders($includeToAndCc = false, $includeBcc = false, $includeSubject = false) { if (!isset($this->_headers['X-Mailer'])) { $this->_headers['X-Mailer'] = Configure::read('Email.XMailer'); if (empty($this->_headers['X-Mailer'])) { $this->_headers['X-Mailer'] = self::EMAIL_CLIENT; } } if (!isset($this->_headers['Date'])) { $this->_headers['Date'] = date(DATE_RFC2822); } if ($includeSubject) { $this->_headers['Subject'] = $this->_subject; } return $this->_headers; } /** * Send an email using the specified content, template and layout * * @return boolean Success */ public function send() { } /** * Reset all EmailComponent internal variables to be able to send out a new email. * * @return void */ public function reset() { } }