本文整理匯總了PHP中CakeEmail::setHeaders方法的典型用法代碼示例。如果您正苦於以下問題:PHP CakeEmail::setHeaders方法的具體用法?PHP CakeEmail::setHeaders怎麽用?PHP CakeEmail::setHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CakeEmail
的用法示例。
在下文中一共展示了CakeEmail::setHeaders方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sendEmail
public function sendEmail($to, $subject, $template = 'default', $content = null, $viewVars = [], $options = [])
{
$defaults = ['emailFormat' => 'html'];
$options = array_merge($defaults, $options);
$email = new CakeEmail();
$email->config('smtp');
$email->config(['from' => ['info@hurad.org' => Configure::read('General.site_name')]]);
$email->to($to);
$email->setHeaders(['X-Mailer' => "Hurad Mail"]);
$email->emailFormat($options['emailFormat']);
$email->template($template);
$email->viewVars($viewVars);
$email->subject($subject);
$email->send($content);
}
示例2: send
/**
* 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 MissingMailerActionException
*/
public function send($action, $args = [], $headers = [])
{
if (!method_exists($this, $action)) {
throw new MissingMailerActionException(['mailer' => get_class($this), 'action' => $action]);
}
$this->_email->setHeaders($headers);
$views = $this->_email->template(false);
if (!$views['template']) {
$this->template($action);
}
call_user_func_array([$this, $action], $args);
$result = $this->_email->send();
$this->_reset();
return $result;
}
示例3: send
/**
* Send an email using the specified content, template and layout
*
* @param string|array $content Either an array of text lines, or a string with contents
* If you are rendering a template this variable will be sent to the templates as `$content`
* @param string $template Template to use when sending email
* @param string $layout Layout to use to enclose email body
* @return boolean Success
*/
public function send($content = null, $template = null, $layout = null) {
$lib = new CakeEmail();
$lib->charset = $this->charset;
$lib->headerCharset = $this->charset;
$lib->from($this->_formatAddresses((array)$this->from));
if (!empty($this->to)) {
$lib->to($this->_formatAddresses((array)$this->to));
}
if (!empty($this->cc)) {
$lib->cc($this->_formatAddresses((array)$this->cc));
}
if (!empty($this->bcc)) {
$lib->bcc($this->_formatAddresses((array)$this->bcc));
}
if (!empty($this->replyTo)) {
$lib->replyTo($this->_formatAddresses((array)$this->replyTo));
}
if (!empty($this->return)) {
$lib->returnPath($this->_formatAddresses((array)$this->return));
}
if (!empty($this->readReceipt)) {
$lib->readReceipt($this->_formatAddresses((array)$this->readReceipt));
}
$lib->subject($this->subject)->messageID($this->messageId);
$lib->helpers($this->_controller->helpers);
$headers = array('X-Mailer' => $this->xMailer);
foreach ($this->headers as $key => $value) {
$headers['X-' . $key] = $value;
}
if ($this->date) {
$headers['Date'] = $this->date;
}
$lib->setHeaders($headers);
if ($template) {
$this->template = $template;
}
if ($layout) {
$this->layout = $layout;
}
$lib->template($this->template, $this->layout)->viewVars($this->_controller->viewVars)->emailFormat($this->sendAs);
if (!empty($this->attachments)) {
$lib->attachments($this->_formatAttachFiles());
}
$lib->transport(ucfirst($this->delivery));
if ($this->delivery === 'mail') {
$lib->config(array('eol' => $this->lineFeed, 'additionalParameters' => $this->additionalParams));
} elseif ($this->delivery === 'smtp') {
$lib->config($this->smtpOptions);
} else {
$lib->config(array());
}
$sent = $lib->send($content);
$this->htmlMessage = $lib->message(CakeEmail::MESSAGE_HTML);
if (empty($this->htmlMessage)) {
$this->htmlMessage = null;
}
$this->textMessage = $lib->message(CakeEmail::MESSAGE_TEXT);
if (empty($this->textMessage)) {
$this->textMessage = null;
}
$this->_header = array();
$this->_message = array();
return $sent;
}
示例4: _applyConfig
/**
* Apply the config to an instance
*
* @param object $obj CakeEmail
* @param array $config
* @return void
*/
protected static function _applyConfig(CakeEmail $obj, $config)
{
$simpleMethods = array('from', 'sender', 'to', 'replyTo', 'readReceipt', 'returnPath', 'cc', 'bcc', 'messageId', 'subject', 'viewRender', 'viewVars', 'attachments', 'transport', 'emailFormat');
foreach ($simpleMethods as $method) {
if (isset($config[$method])) {
$obj->{$method}($config[$method]);
unset($config[$method]);
}
}
if (isset($config['headers'])) {
$obj->setHeaders($config['headers']);
unset($config['headers']);
}
if (array_key_exists('template', $config)) {
$layout = false;
if (array_key_exists('layout', $config)) {
$layout = $config['layout'];
unset($config['layout']);
}
$obj->template($config['template'], $layout);
unset($config['template']);
}
$obj->config($config);
}