本文整理汇总了PHP中CakeEmail::to方法的典型用法代码示例。如果您正苦于以下问题:PHP CakeEmail::to方法的具体用法?PHP CakeEmail::to怎么用?PHP CakeEmail::to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CakeEmail
的用法示例。
在下文中一共展示了CakeEmail::to方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* Sends out email via Mandrill
*
* @param CakeEmail $email
* @return array
*/
public function send(CakeEmail $email)
{
// CakeEmail
$this->_cakeEmail = $email;
$from = $this->_cakeEmail->from();
list($fromEmail) = array_keys($from);
$fromName = $from[$fromEmail];
$this->_config = $this->_cakeEmail->config();
$this->_headers = $this->_cakeEmail->getHeaders();
$message = array('html' => $this->_cakeEmail->message('html'), 'text' => $this->_cakeEmail->message('text'), 'subject' => mb_decode_mimeheader($this->_cakeEmail->subject()), 'from_email' => $fromEmail, 'from_name' => $fromName, 'to' => array(), 'headers' => array('Reply-To' => $fromEmail), 'important' => false, 'track_opens' => null, 'track_clicks' => null, 'auto_text' => null, 'auto_html' => null, 'inline_css' => null, 'url_strip_qs' => null, 'preserve_recipients' => null, 'view_content_link' => null, 'tracking_domain' => null, 'signing_domain' => null, 'return_path_domain' => null, 'merge' => true, 'tags' => null, 'subaccount' => null);
$message = array_merge($message, $this->_headers);
foreach ($this->_cakeEmail->to() as $email => $name) {
$message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'to');
}
foreach ($this->_cakeEmail->cc() as $email => $name) {
$message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'cc');
}
foreach ($this->_cakeEmail->bcc() as $email => $name) {
$message['to'][] = array('email' => $email, 'name' => $name, 'type' => 'bcc');
}
$attachments = $this->_cakeEmail->attachments();
if (!empty($attachments)) {
$message['attachments'] = array();
foreach ($attachments as $file => $data) {
$message['attachments'][] = array('type' => $data['mimetype'], 'name' => $file, 'content' => base64_encode(file_get_contents($data['file'])));
}
}
$params = array('message' => $message, "async" => false, "ip_pool" => null, "send_at" => null);
return $this->_exec($params);
}
示例2: send
/**
* Sends out email via SparkPost
*
* @param CakeEmail $email
* @return array
*/
public function send(CakeEmail $email)
{
// CakeEmail
$this->_cakeEmail = $email;
$this->_config = $this->_cakeEmail->config();
$this->_headers = $this->_cakeEmail->getHeaders();
// Not allowed by SparkPost
unset($this->_headers['Content-Type']);
unset($this->_headers['Content-Transfer-Encoding']);
unset($this->_headers['MIME-Version']);
unset($this->_headers['X-Mailer']);
$from = $this->_cakeEmail->from();
list($fromEmail) = array_keys($from);
$fromName = $from[$fromEmail];
$message = ['html' => $this->_cakeEmail->message('html'), 'text' => $this->_cakeEmail->message('text'), 'from' => ['name' => $fromName, 'email' => $fromEmail], 'subject' => mb_decode_mimeheader($this->_cakeEmail->subject()), 'recipients' => [], 'transactional' => true];
foreach ($this->_cakeEmail->to() as $email => $name) {
$message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
}
foreach ($this->_cakeEmail->cc() as $email => $name) {
$message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
}
foreach ($this->_cakeEmail->bcc() as $email => $name) {
$message['recipients'][] = ['address' => ['email' => $email, 'name' => $name], 'tags' => $this->_headers['tags']];
}
unset($this->_headers['tags']);
$attachments = $this->_cakeEmail->attachments();
if (!empty($attachments)) {
$message['attachments'] = array();
foreach ($attachments as $file => $data) {
if (!empty($data['contentId'])) {
$message['inlineImages'][] = array('type' => $data['mimetype'], 'name' => $data['contentId'], 'data' => base64_encode(file_get_contents($data['file'])));
} else {
$message['attachments'][] = array('type' => $data['mimetype'], 'name' => $file, 'data' => base64_encode(file_get_contents($data['file'])));
}
}
}
$message = array_merge($message, $this->_headers);
// Load SparkPost configuration settings
$config = ['key' => $this->_config['sparkpost']['api_key']];
if (isset($this->_config['sparkpost']['timeout'])) {
$config['timeout'] = $this->_config['sparkpost']['timeout'];
}
// Set up HTTP request adapter
$httpAdapter = new Ivory\HttpAdapter\Guzzle6HttpAdapter($this->__getClient());
// Create SparkPost API accessor
$sparkpost = new SparkPost\SparkPost($httpAdapter, $config);
// Send message
try {
return $sparkpost->transmission->send($message);
} catch (SparkPost\APIResponseException $e) {
// TODO: Determine if BRE is the best exception type
throw new BadRequestException(sprintf('SparkPost API error %d (%d): %s (%s)', $e->getAPICode(), $e->getCode(), ucfirst($e->getAPIMessage()), $e->getAPIDescription()));
}
}
示例3: 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');
}
示例4: register
public function register()
{
if ($this->request->is('post')) {
if ($this->data['User']['password'] == $this->data['User']['password_confirm']) {
$this->request->data['User']['role'] = 'student';
$this->User->create();
if ($this->User->save($this->request->data)) {
App::uses('CakeEmail', 'Network/Email');
$user = $this->User->read(null, $this->User->id);
$link = array('controller' => 'users', 'action' => 'activate', $this->User->id . '-' . md5($user['User']['password']));
$mail = new CakeEmail('gmail');
$mail->from("test.cour.php@gmail.com");
$mail->to($this->request->data['User']['email']);
$mail->subject(__('Please confirm your email !'));
$mail->emailFormat('html');
$mail->template('signup');
$mail->viewVars(array('username' => $this->request->data['User']['username'], 'link' => $link));
$mail->send();
$this->redirect(array('action' => 'login'));
}
} else {
$this->Flash->error(__('The passwords do not match.'));
}
}
}
示例5: send
/**
* Send email via Mailgun
*
* @param CakeEmail $email
* @return array
* @throws Exception
*/
public function send(CakeEmail $email)
{
if (Configure::read('Mailgun.preventManyToRecipients') !== false && count($email->to()) > 1) {
throw new Exception('More than one "to" recipient not allowed (set Mailgun.preventManyToRecipients = false to disable check)');
}
$mgClient = new Mailgun($this->_config['mg_api_key']);
$headersList = array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject');
$params = [];
foreach ($email->getHeaders($headersList) as $header => $value) {
if (isset($this->_paramMapping[$header]) && !empty($value)) {
$key = $this->_paramMapping[$header];
$params[$key] = $value;
}
}
$params['text'] = $email->message(CakeEmail::MESSAGE_TEXT);
$params['html'] = $email->message(CakeEmail::MESSAGE_HTML);
$attachments = array();
foreach ($email->attachments() as $name => $info) {
$attachments['attachment'][] = '@' . $info['file'];
}
try {
$result = $mgClient->sendMessage($this->_config['mg_domain'], $params, $attachments);
if ($result->http_response_code != 200) {
throw new Exception($result->http_response_body->message);
}
} catch (Exception $e) {
throw $e;
}
return $result;
}
示例6: _prepareRecipientAddresses
/**
* Prepares the recipient email addresses.
*
* @return array
*/
protected function _prepareRecipientAddresses()
{
$to = $this->_cakeEmail->to();
$cc = $this->_cakeEmail->cc();
$bcc = $this->_cakeEmail->bcc();
return array_merge(array_keys($to), array_keys($cc), array_keys($bcc));
}
示例7: send
public function send()
{
if ($this->request->is('post')) {
// Check security token
if (empty($this->request->data['Feedback']['token']) || $this->request->data['Feedback']['token'] != '!pilule$') {
throw new NotFoundException();
}
// Send feedback via email
$Email = new CakeEmail();
if (!empty($this->request->data['Feedback']['name']) && !empty($this->request->data['Feedback']['email'])) {
$Email->replyTo(array($this->request->data['Feedback']['email'] => $this->request->data['Feedback']['name']));
}
$Email->from('web@alexandreclement.com');
$Email->to('web@alexandreclement.com');
$Email->config('postmark');
$Email->subject('Pilule - Commentaires');
$Email->template('feedback');
$Email->emailFormat('html');
$Email->viewVars(array('message' => $this->request->data));
if ($Email->send()) {
return new CakeResponse(array('body' => json_encode(array('status' => true))));
} else {
return new CakeResponse(array('body' => json_encode(array('status' => false))));
}
} elseif ($this->request->is('ajax')) {
$this->layout = 'ajax';
$this->render('modals/form');
}
}
示例8: exacute
public function exacute()
{
$books = $this->Book->find('all', array('conditions' => array('Book.state' => 'Bet Finish')));
foreach ($books as $book) {
$time_zone = $this->Book->TimeZone->find('first', array('conditions' => array('TimeZone.id' => $book['Book']['time_zone'])));
if (isset($time_zone['TimeZone']) && isset($time_zone['TimeZone']['value'])) {
$bookdaystate = new BookDayState($book, $time_zone['TimeZone']['value']);
if ($bookdaystate->isTimeOut() && $book['Book']['timeover_info'] == false) {
/*
$content = 'The result has not been selected after 24 hours from the announcement date and time the corresponding book is disabled and all points wagered are returned to all punters.
The bookmaker will receive a penalty.
Book Title : '.$book['Book']['title'].'<br>Total Bet : '.$book['Book']['bet_all_total'].'<br>Total User : '.$book['Book']['user_all_count'].'
'.'<a href="http://bookbookmaker.com/books'.'/'.$book['Book']['id'].'">http://bookbookmaker.com/books'.'/'.$book['Book']['id'].'</a>';
*/
$Email = new CakeEmail('sendGrid');
$Email->template('timeover');
$Email->to($book['User']['mail']);
$Email->subject('Bookタイムオーバー bookbookmaker.com');
$Email->viewVars(array('book' => $book));
$Email->send();
$this->Book->seTimeover($book['Book']['id']);
} else {
}
}
}
}
示例9: contact
public function contact()
{
$this->loadModel('Contact');
if ($this->request->is('post')) {
$this->Contact->set($this->request->data);
if ($this->Contact->validates()) {
App::uses('CakeEmail', 'Network/Email');
if ($this->request->data['Contact']['subject'] == '') {
$this->request->data['Contact']['subject'] = 'Contact';
}
$Email = new CakeEmail('smtp');
$Email->viewVars(array('mailData' => $this->request->data));
$Email->template('contact', 'default');
$Email->emailFormat('html');
$Email->from(array($this->request->data['Contact']['mail'] => $this->request->data['Contact']['name']));
$Email->to('contact@youthbook.be');
$Email->subject($this->request->data['Contact']['subject']);
$Email->attachments(array('logo.png' => array('file' => WWW_ROOT . '/img/icons/logo.png', 'mimetype' => 'image/png', 'contentId' => 'logo')));
$Email->send();
$this->Flash->success(__('Votre mail a bien été envoyé.'));
return $this->redirect($this->referer());
} else {
$this->Session->write('errors.Contact', $this->Contact->validationErrors);
$this->Session->write('data', $this->request->data);
$this->Session->write('flash', 'Le mail n’a pas pu être envoyé. Veuillez réessayer SVP.');
return $this->redirect($this->referer());
}
}
}
示例10: CakeEmail
function email_referrer($receiver = null, $invite_total = null, $code = null)
{
$share_link = FULL_BASE_URL . '/invite/' . $code;
//For our coming soon incentive, we were increasing peoples call rates by 10 cents for every person that joined the site from their link
//so the funciton below simply calculates their new rate.
//add in your own function if you want
$total_referrals = $invite_total;
$current_rate = 2.5 + $invite_total * 0.1;
if ($current_rate > 3.5) {
$current_rate = 3.5;
}
$message = 'Nice work!
<br /><br />
One of your friends just joined Amplifyd. Your new caller rate is now $' . $current_rate . '0/per call.
<br /><br />
Because of you, our public voice just got stronger and louder.
<br /><br />
Keep it up, here\'s your unique invite link again:
<br />
<a href="' . $share_link . '" >' . $share_link . '</a>
<br /><br />
';
$email = new CakeEmail('sendgrid');
$email->emailFormat('html');
$email->to($receiver);
$email->subject('A Friend Just Joined');
$email->send($message);
}
开发者ID:suspended,项目名称:CakePHP-Coming-Soon-Website-With-Referral-Rewards,代码行数:28,代码来源:SignupsController.php
示例11: main
public function main()
{
define('TIMEZONE', 'Asia/Bangkok');
date_default_timezone_set(TIMEZONE);
$now = date("Y-m-d H:i:s");
$tomorrow = date("Y-m-d H:i:s", time() + EVENT_REMIDER_TIMER);
$optionCalendar = array('order' => array('from_date' => 'asc'), 'conditions' => array('from_date >=' => $now, 'to_date <=' => $tomorrow));
$events = $this->Calendar->find("all", $optionCalendar);
foreach ($events as $key => $event) {
$content = array();
$content["id"] = $event["Calendar"]["id"];
$content["name"] = $event["Calendar"]["name"];
$content["description"] = $event["Calendar"]["description"];
$content["from_date"] = $this->_formatDate($events[$key]["Calendar"]["from_date"], "d-m-Y H:i");
$content["to_date"] = $this->_formatDate($events[$key]["Calendar"]["to_date"], "d-m-Y H:i");
$id = $event["Calendar"]["id"];
$user = $this->UserModel->findById($event["Calendar"]["user_id"]);
$content["receive_name"] = $user["UserModel"]["display_name"];
$Email = new CakeEmail('noreply');
$noreplyConf = $Email->config();
$Email->template('calendar_remider');
$Email->emailFormat('html');
$Email->viewVars(array('emailContent' => $content));
$Email->from($noreplyConf['from']);
$Email->to($user["UserModel"]["user_email"]);
$Email->subject(__('Calendar Reminder'));
$Email->send();
}
//echo EVENT_REMIDER_TIMER;
}
示例12: send
/**
* Send email via SNS
* @param CakeEmail $email
* @return bool
*/
public function send(CakeEmail $email)
{
$ses = SesClient::factory(array("key" => "AKIAIQHPCMQTEEXD5MGA", "secret" => "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", 'region' => 'us-east-1'));
$destination = array('ToAddresses' => array());
foreach ($email->to() as $addr => $name) {
$destination['ToAddresses'][] = "{$name} <{$addr}>";
}
foreach ($email->bcc() as $addr => $name) {
$destination['BccAddresses'][] = "{$name} <{$addr}>";
}
$message = array('Subject' => array('Data' => $email->subject()), 'Body' => array());
$text = $email->message('text');
if (!empty($text)) {
$message['Body']['Text'] = array('Data' => $text);
}
$html = $email->message('html');
if (!empty($html)) {
$message['Body']['Html'] = array('Data' => $html);
}
$from = '';
foreach ($email->from() as $addr => $name) {
$from = "{$name} <{$addr}>";
break;
}
$response = $ses->sendEmail(['Source' => $from, 'Destination' => $destination, 'Message' => $message]);
return !empty($response);
}
示例13: sendEmail
public function sendEmail($event)
{
$user_email = $event->subject()->data['User']['email'];
App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail('default');
$email->to($user_email)->subject(__('Welcome on Sonerezh !'))->emailFormat('html')->template('userAdd')->send();
}
示例14: index
public function index()
{
if (!empty($this->data)) {
if ($this->request->is('post')) {
$data = $this->request->data;
if ($this->Matriculation->save($data)) {
$email = new CakeEmail();
$email->config('default');
$email->from(array('contato@sardonixidiomas.com' => 'Sardonix Idiomas | Automático'));
$email->to('contato@sardonixidiomas.com');
$email->subject("Matrícula - {$data['Matriculation']['name']} ");
$cursos = '';
if (isset($data['Matriculation']['english'])) {
$cursos .= 'Inglês; ';
}
if (isset($data['Matriculation']['italian'])) {
$cursos .= 'Italiano; ';
}
if (isset($data['Matriculation']['portuguese'])) {
$cursos .= 'Português; ';
}
$date = new DateTime();
$message = "Nome: {$data['Matriculation']['name']}\n\n";
$message .= "Telefone: {$data['Matriculation']['phone']}\n\n";
$message .= "Celular: {$data['Matriculation']['cellphone']}\n\n";
$message .= "Idiomas de interesse: {$cursos}\n\n";
$message .= "E-mail: {$data['Matriculation']['email']} \n\n";
$message .= "Soube: {$data['Matriculation']['where']}\n\n";
$message .= "Acessou em: " . $date->format('d/m/Y H:i:s');
$email->send($message);
$this->render('enviado');
}
}
}
}
示例15: send_mail
/**
* Send comfirmation email whit unique code
*/
public function send_mail()
{
$user = $this->Session->read('Auth');
if (isset($user)) {
if ($user['User']['active'] == 0) {
$uniqueId = uniqid("", TRUE);
if ($this->saveSendComfirmation($user, $uniqueId)) {
App::uses('CakeEmail', 'Network/Email');
$email = new CakeEmail('gmail');
$link = "http://" . $_SERVER['HTTP_HOST'] . $this->webroot . "email/activate_account/" . $user['User']['id'] . '-' . $uniqueId;
$email->from('stagesstatcoordonateur@gmail.com');
$email->to($user['User']['email']);
$email->subject('Mail Confirmation');
$email->emailFormat('html');
$email->template('signup');
$email->viewVars(array('username' => $user['User']['full_name'], 'link' => $link));
$this->Session->setFlash(__('Email comfirmation has been sent'), 'flash/success');
$email->send();
} else {
$this->Session->setFlash(__('Could not send email.'), 'flash/error');
}
} else {
$this->Session->setFlash(__('Your email is already comfirmed.'), 'flash/error');
}
} else {
$this->Session->setFlash(__('You are not login.'), 'flash/error');
}
$this->redirect('/');
}