本文整理汇总了PHP中CakeEmail::addHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeEmail::addHeaders方法的具体用法?PHP CakeEmail::addHeaders怎么用?PHP CakeEmail::addHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeEmail
的用法示例。
在下文中一共展示了CakeEmail::addHeaders方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPostmarkSend
/**
* testSendgridSend method
*
* @return void
*/
public function testPostmarkSend()
{
$this->email->template('default', 'default');
$this->email->emailFormat('both');
$this->email->to(array('test1@example.com' => 'Recipient'));
$this->email->subject('Test email via SedGrid');
$this->email->addHeaders(array('X-Tag' => 'my tag'));
$sendReturn = $this->email->send();
// $headers = $this->email->getHeaders(array('to'));
// $this->assertEqual($sendReturn['To'], $headers['To']);
// $this->assertEqual($sendReturn['ErrorCode'], 0);
// $this->assertEqual($sendReturn['Message'], 'OK');
}
示例2: testPostmarkSend
/**
* testPostmarkSend method
*
* @return void
*/
public function testPostmarkSend()
{
$this->email->config('postmark');
$this->email->template('default', 'default');
$this->email->emailFormat('html');
$this->email->from(array('yourpostmark@mail.com' => 'Your Name'));
$this->email->to(array('recipient@domain.com' => 'Recipient'));
$this->email->cc(array('recipient@domain.com' => 'Recipient'));
$this->email->bcc(array('recipient@domain.com' => 'Recipient'));
$this->email->subject('Test Postmark');
$this->email->addHeaders(array('Tag' => 'my tag'));
$this->email->attachments(array('cake.icon.png' => array('file' => WWW_ROOT . 'img' . DS . 'cake.icon.png')));
$sendReturn = $this->email->send();
$headers = $this->email->getHeaders(array('to'));
$this->assertEqual($sendReturn['To'], $headers['To']);
$this->assertEqual($sendReturn['ErrorCode'], 0);
$this->assertEqual($sendReturn['Message'], 'OK');
}
示例3: send
/**
* Send mail
*
* @params object $email CakeEmail
* @return boolean
*/
public function send(CakeEmail $email)
{
$email->addHeaders(array('Date' => EmailComponentTest::$sentDate));
$headers = $email->getHeaders(array_fill_keys(array('from', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject'), true));
$to = $headers['To'];
$subject = $headers['Subject'];
unset($headers['To'], $headers['Subject']);
$message = implode("\n", $email->message());
$last = '<pre>';
$last .= sprintf("%s %s\n", 'To:', $to);
$last .= sprintf("%s %s\n", 'From:', $headers['From']);
$last .= sprintf("%s %s\n", 'Subject:', $subject);
$last .= sprintf("%s\n\n%s", 'Header:', $this->_headersToString($headers, "\n"));
$last .= sprintf("%s\n\n%s", 'Message:', $message);
$last .= '</pre>';
self::$lastEmail = $last;
return true;
}
示例4: CakeEmail
/**
* Descripción de la función
*
* @param tipo $parametro1 descripción del párametro 1.
* @return tipo descripcion de lo que regresa
* @access publico/privado
* @link [URL de mayor infor]
*/
function _notificarTaller()
{
$slug = NULL;
$slug = $this->Taller->slugStr($this->request->data['Taller']['nombre']);
if ($slug) {
$urlInfo = Router::url('/', true) . 'talleres/ver/' . $slug;
$msg = "<h1><a href='{$urlInfo}' style='color:#C2570B;text-decoration:none'>" . "\n{$this->request->data['Taller']['nombre']}\n</a></h1>";
$msg .= "<h4>{$this->request->data['Taller']['resumen']}</h4>" . "<h2>Descripción:</h2>" . $this->request->data['Taller']['contenido'];
$msg .= "<br /><strong>Mayores informes: </strong>\n<a href={$urlInfo}>{$urlInfo}</a>";
$usuarios_a_notificar = $this->Taller->User->notificados();
App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail('default');
$email->subject('Notificación Taller ' . $this->request->data['Taller']['nombre']);
$email->addHeaders(array('X-Mailer' => 'adsl.org.mx'));
foreach ($usuarios_a_notificar as $username => $member_email) {
$email->to($member_email);
$email->send($msg);
}
}
return $slug;
}
示例5: sendmail
function sendmail($to, $template = 'email', $fromname = '1337 Institute of Technology')
{
App::uses('CakeEmail', 'Network/Email');
if (isset($this->params->base) && !empty($this->params->base)) {
$email = new CakeEmail("gmail");
} else {
$email = new CakeEmail();
}
if (filter_var($to, FILTER_VALIDATE_EMAIL)) {
$email->from(array($this->from => $fromname));
$email->to($to);
$email->subject($this->subject);
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$email->addHeaders($headers);
$email->emailFormat('both');
if (empty($template)) {
try {
$email->send($this->mailBody);
return true;
} catch (Exception $e) {
$e->getMessage();
return false;
}
} else {
if (!empty($this->mailBody)) {
$email->viewVars(array("mail" => $this->mailBody));
}
$email->template($template, 'default');
try {
$email->send();
return true;
} catch (Exception $e) {
$e->getMessage();
return false;
}
}
} else {
return false;
}
}
示例6: nuevaContribucion
function nuevaContribucion($c)
{
$tipo_cambio = array('added' => array('titulo' => 'Archivos añadidos', 'color' => '055FBF', 'tag' => 'span'), 'modified' => array('titulo' => 'Archivos modificados', 'color' => 'CD4D00', 'tag' => 'span'), 'removed' => array('titulo' => 'Archivos eliminados', 'color' => '660000', 'tag' => 'del'));
$newCommit = array('Contribucion' => array('hash' => $c['id'], 'author_name' => $c['author']['username'], 'author_email' => $c['author']['email'], 'message' => $c['message'], 'added' => implode("\n", $c['added']), 'modified' => implode("\n", $c['modified']), 'removed' => implode("\n", $c['removed']), 'timestamp' => str_replace('T', ' ', substr($c['timestamp'], 0, 19))));
$urlInfo = Router::url('/', true) . 'contribuciones/ver/' . $c['id'];
$title = explode("\n", $c['message']);
$commit_msg = '';
$msg = $c['message'];
if (count($title)) {
$commit_msg .= '<h2>' . $title[0] . '</h2>';
$msg = str_replace($title[0], '', $msg);
}
$commit_msg .= '<strong>Autor:</strong> ' . $c['author']['username'] . '<br />';
$commit_msg .= '<strong>Autor-Email:</strong> ' . $c['author']['email'] . '<br />';
$commit_msg .= '<strong>Hash:</strong> ' . $c['id'] . '<br />';
$commit_msg .= '<strong>Fecha:</strong> ' . $c['timestamp'] . '<br />';
if (strlen($msg) > 5) {
$commit_msg .= '<h2>Mensaje:</h2><pre style="background:#EEE;padding:0 5px 0 5px">' . $msg . '</pre>';
}
foreach ($tipo_cambio as $t => $t_data) {
//$tipo_cambio
if (count($c[$t])) {
$commit_msg .= '<h2>' . $t_data['titulo'] . '</h2>';
$character = strtoupper($t[0]);
$commit_msg .= '<ul>';
foreach ($c[$t] as $m) {
$commit_msg .= '<li><' . $t_data['tag'] . ' style="color:#' . $t_data['color'] . '">' . '[' . $character . '] ' . $m . '</' . $t_data['tag'] . "></li>\n";
}
$commit_msg .= '</ul>';
}
}
///////////////////
$commit_msg .= '<br /><strong>Mayores informes: </strong><a href="' . $urlInfo . '">' . $urlInfo . '</a>';
App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail('colaboradores');
$email->subject(count($title) ? $title[0] : 'Notificación de cambios - contribución repositorio ADSL');
$email->addHeaders(array('X-Mailer' => 'adsl.org.mx'));
$email->replyTo($c['author']['email']);
$email->send($commit_msg);
$this->Contribucion->save($newCommit);
}