当前位置: 首页>>代码示例>>PHP>>正文


PHP Email::viewVars方法代码示例

本文整理汇总了PHP中Cake\Mailer\Email::viewVars方法的典型用法代码示例。如果您正苦于以下问题:PHP Email::viewVars方法的具体用法?PHP Email::viewVars怎么用?PHP Email::viewVars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Mailer\Email的用法示例。


在下文中一共展示了Email::viewVars方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: mailer

 /**
  * mailer method
  *
  * @param array $data Dados para formar o email.
  * @return boolean True ou False.
  */
 public function mailer($data, $template, $subject)
 {
     $email = new Email();
     $email->transport('mailSgl');
     $email->emailFormat('html');
     $email->template($template);
     $email->from('sglmailer@gmail.com', 'SGL');
     $email->to($data['email'], $data['nome']);
     $email->viewVars($data);
     $email->subject($subject);
     $email->send();
 }
开发者ID:daniels85,项目名称:SGL,代码行数:18,代码来源:AppController.php

示例2: testSendWithEmail

 /**
  * @return void
  */
 public function testSendWithEmail()
 {
     $config = ['transport' => 'queue', 'charset' => 'utf-8', 'headerCharset' => 'utf-8'];
     $this->QueueTransport->config($config);
     $Email = new Email($config);
     $Email->from('noreply@cakephp.org', 'CakePHP Test');
     $Email->to('cake@cakephp.org', 'CakePHP');
     $Email->cc(['mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso']);
     $Email->bcc('phpnut@cakephp.org');
     $Email->subject('Testing Message');
     $Email->attachments(['wow.txt' => ['data' => 'much wow!', 'mimetype' => 'text/plain', 'contentId' => 'important']]);
     $Email->template('test_template', 'test_layout');
     $Email->subject("L'utilisateur n'a pas pu être enregistré");
     $Email->replyTo('noreply@cakephp.org');
     $Email->readReceipt('noreply2@cakephp.org');
     $Email->returnPath('noreply3@cakephp.org');
     $Email->domain('cakephp.org');
     $Email->theme('EuroTheme');
     $Email->emailFormat('both');
     $Email->set('var1', 1);
     $Email->set('var2', 2);
     $result = $this->QueueTransport->send($Email);
     $this->assertEquals('Email', $result['job_type']);
     $this->assertTrue(strlen($result['data']) < 10000);
     $output = json_decode($result['data'], true);
     $emailReconstructed = new Email($config);
     foreach ($output['settings'] as $method => $setting) {
         call_user_func_array([$emailReconstructed, $method], (array) $setting);
     }
     $this->assertEquals($emailReconstructed->from(), $Email->from());
     $this->assertEquals($emailReconstructed->to(), $Email->to());
     $this->assertEquals($emailReconstructed->cc(), $Email->cc());
     $this->assertEquals($emailReconstructed->bcc(), $Email->bcc());
     $this->assertEquals($emailReconstructed->subject(), $Email->subject());
     $this->assertEquals($emailReconstructed->charset(), $Email->charset());
     $this->assertEquals($emailReconstructed->headerCharset(), $Email->headerCharset());
     $this->assertEquals($emailReconstructed->emailFormat(), $Email->emailFormat());
     $this->assertEquals($emailReconstructed->replyTo(), $Email->replyTo());
     $this->assertEquals($emailReconstructed->readReceipt(), $Email->readReceipt());
     $this->assertEquals($emailReconstructed->returnPath(), $Email->returnPath());
     $this->assertEquals($emailReconstructed->messageId(), $Email->messageId());
     $this->assertEquals($emailReconstructed->domain(), $Email->domain());
     $this->assertEquals($emailReconstructed->theme(), $Email->theme());
     $this->assertEquals($emailReconstructed->profile(), $Email->profile());
     $this->assertEquals($emailReconstructed->viewVars(), $Email->viewVars());
     $this->assertEquals($emailReconstructed->template(), $Email->template());
     //for now cannot be done 'data' is base64_encode on set but not decoded when get from $email
     //$this->assertEquals($emailReconstructed->attachments(),$Email->attachments());
     //$this->assertEquals($Email, $output['settings']);
 }
开发者ID:dereuromark,项目名称:cakephp-queue,代码行数:53,代码来源:SimpleQueueTransportTest.php

示例3: run

 /**
  * @param mixed $data Job data
  * @param int|null $id The id of the QueuedTask
  * @return bool Success
  */
 public function run(array $data, $id)
 {
     if (!isset($data['settings'])) {
         $this->err('Queue Email task called without settings data.');
         return false;
     }
     /* @var \Cake\Mailer\Email $email */
     $email = $data['settings'];
     if (is_object($email) && $email instanceof Email) {
         try {
             $transportClassNames = $email->configuredTransport();
             $result = $email->transport($transportClassNames[0])->send();
             if (!isset($config['log']) || !empty($config['logTrace']) && $config['logTrace'] === true) {
                 $config['log'] = 'email_trace';
             } elseif (!empty($config['logTrace'])) {
                 $config['log'] = $config['logTrace'];
             }
             if (isset($config['logTrace']) && !$config['logTrace']) {
                 $config['log'] = false;
             }
             if (!empty($config['logTrace'])) {
                 $this->_log($result, $config['log']);
             }
             return (bool) $result;
         } catch (Exception $e) {
             $error = $e->getMessage();
             $error .= ' (line ' . $e->getLine() . ' in ' . $e->getFile() . ')' . PHP_EOL . $e->getTraceAsString();
             Log::write('email_error', $error);
             return false;
         }
     }
     $class = 'Tools\\Mailer\\Email';
     if (!class_exists($class)) {
         $class = 'Cake\\Mailer\\Email';
     }
     $this->Email = new $class();
     $settings = array_merge($this->defaults, $data['settings']);
     foreach ($settings as $method => $setting) {
         call_user_func_array([$this->Email, $method], (array) $setting);
     }
     $message = null;
     if (!empty($data['vars'])) {
         if (isset($data['vars']['content'])) {
             $message = $data['vars']['content'];
         }
         $this->Email->viewVars($data['vars']);
     }
     return (bool) $this->Email->send($message);
 }
开发者ID:dereuromark,项目名称:cakephp-queue,代码行数:54,代码来源:QueueEmailTask.php

示例4: _sendActivationEmail

 /**
  * Send an activation link to user email
  * @param $user
  */
 public function _sendActivationEmail(Entity $user, $url = '/register/active/')
 {
     $ActivationKeys = TableRegistry::get('Users.ActivationKeys');
     $activationKeyEntity = $ActivationKeys->newEntity();
     $activationKeyEntity->user_id = $user->id;
     do {
         $activationKeyEntity->activation_key = Text::uuid();
     } while (!$ActivationKeys->save($activationKeyEntity));
     //send email with activation key
     $activationUrl = Router::url($url . $activationKeyEntity->activation_key, true);
     $email = new Email('default');
     //        $email->transport();
     $email->emailFormat('html');
     $email->viewVars(compact('activationUrl'));
     $email->helpers(['Html']);
     $email->to($user->username);
     return $email;
 }
开发者ID:mohammadsaleh,项目名称:spider,代码行数:22,代码来源:AppController.php

示例5: sendNewMissionsToInterestedUsers

 public function sendNewMissionsToInterestedUsers($nbrDays = 7)
 {
     $created = Time::now()->subDays($nbrDays);
     $missions = $this->Missions->find('all', ['conditions' => ['Missions.created >=' => $created]])->toArray();
     $newMissions = [];
     foreach ($missions as $mission) {
         $users = $this->Users->find('all')->toArray();
         foreach ($users as $user) {
             $usersTypeMissions = $this->UsersTypeMissions->findByUserId($user['id'])->toArray();
             foreach ($usersTypeMissions as $userTypeMissions) {
                 // Check if the current mission has the same type has the current userType mission
                 if ($userTypeMissions['type_mission_id'] == $mission['type_mission_id']) {
                     // Add a new mission to the list of missions to send
                     if (isset($newMissions[$user['email']])) {
                         $newMission = [];
                         $newMission['link'] = Router::url(['controller' => 'Missions', 'action' => 'view', $mission['id']]);
                         $newMission['name'] = $mission['name'];
                         //print("Mission " . $newMission['name'] . " added to user " . $user['email'] . "\n");
                         array_push($newMissions[$user['email']], $newMission);
                     } else {
                         //print("Creating mission list for user " . $user['email'] . "\n");
                         $newMissions[$user['email']] = [];
                         $newMission = [];
                         $newMission['link'] = Router::url(['controller' => 'Missions', 'action' => 'view', $mission['id']]);
                         $newMission['name'] = $mission['name'];
                         //print("Mission " . $newMission['name'] . " added to user " . $user['email'] . "\n");
                         array_push($newMissions[$user['email']], $newMission);
                     }
                 }
             }
         }
     }
     // For each user send their associated list of missions
     foreach ($newMissions as $userEmail => $missionsToSend) {
         $email = new Email();
         $email->domain('maisonlogiciellibre.org');
         $email->to($userEmail);
         $email->subject('New missions available at ML2');
         $email->template('new_missions');
         $email->emailFormat('both');
         $email->viewVars(['missions' => $missionsToSend]);
         $email->send();
     }
 }
开发者ID:fxleblanc,项目名称:Website,代码行数:44,代码来源:SendMailShell.php

示例6: send

 /**
  * Send mail
  *
  * @param \Cake\Mailer\Email $email Email
  * @return array
  */
 public function send(Email $email)
 {
     if (!empty($this->_config['queue'])) {
         $this->_config = $this->_config['queue'] + $this->_config;
         $email->config((array) $this->_config['queue'] + ['queue' => []]);
         unset($this->_config['queue']);
     }
     $settings = ['from' => [$email->from()], 'to' => [$email->to()], 'cc' => [$email->cc()], 'bcc' => [$email->bcc()], 'charset' => [$email->charset()], 'replyTo' => [$email->replyTo()], 'readReceipt' => [$email->readReceipt()], 'returnPath' => [$email->returnPath()], 'messageId' => [$email->messageId()], 'domain' => [$email->domain()], 'getHeaders' => [$email->getHeaders()], 'headerCharset' => [$email->headerCharset()], 'theme' => [$email->theme()], 'profile' => [$email->profile()], 'emailFormat' => [$email->emailFormat()], 'subject' => [$email->getOriginalSubject()], 'transport' => [$this->_config['transport']], 'attachments' => [$email->attachments()], 'template' => $email->template(), 'viewVars' => [$email->viewVars()]];
     foreach ($settings as $setting => $value) {
         if (array_key_exists(0, $value) && ($value[0] === null || $value[0] === [])) {
             unset($settings[$setting]);
         }
     }
     $QueuedTasks = TableRegistry::get('Queue.QueuedTasks');
     $result = $QueuedTasks->createJob('Email', ['settings' => $settings]);
     $result['headers'] = '';
     $result['message'] = '';
     return $result;
 }
开发者ID:alexandreanfilo,项目名称:cakephp-queue,代码行数:25,代码来源:SimpleQueueTransport.php

示例7: send

 /**
  * Send notification
  *
  * @param \CvoTechnologies\Notifier\Notification $notification Notification instance.
  * @return array
  */
 public function send(Notification $notification)
 {
     $email = new Email();
     $email->profile($this->config('profile'));
     $email->to($notification->to(null, static::TYPE));
     $email->subject($notification->title());
     $email->viewBuilder()->templatePath($notification->viewBuilder()->templatePath());
     $email->viewBuilder()->template($notification->viewBuilder()->template());
     $email->viewBuilder()->plugin($notification->viewBuilder()->plugin());
     $email->viewBuilder()->theme($notification->viewBuilder()->theme());
     $email->viewBuilder()->layout($notification->viewBuilder()->layout());
     $email->viewBuilder()->autoLayout($notification->viewBuilder()->autoLayout());
     $email->viewBuilder()->layoutPath($notification->viewBuilder()->layoutPath());
     $email->viewBuilder()->name($notification->viewBuilder()->name());
     $email->viewBuilder()->className($notification->viewBuilder()->className());
     $email->viewBuilder()->options($notification->viewBuilder()->options());
     $email->viewBuilder()->helpers($notification->viewBuilder()->helpers());
     $email->viewVars($notification->viewVars());
     return $email->send();
 }
开发者ID:cvo-technologies,项目名称:cakephp-notifier,代码行数:26,代码来源:EmailTransport.php

示例8: set

 /**
  * Sets email view vars.
  *
  * @param string|array $key Variable name or hash of view variables.
  * @param mixed $value View variable value.
  * @return $this object.
  */
 public function set($key, $value = null)
 {
     $this->_email->viewVars(is_string($key) ? [$key => $value] : $key);
     return $this;
 }
开发者ID:hossain-seaos,项目名称:cakephp,代码行数:12,代码来源:Mailer.php

示例9: sendPasswordResetEmail

 /**
  * Sends an email with a link that can be used in the next
  * 24 hours to give the user access to /users/resetPassword
  *
  * @param int $userId User ID
  * @return array
  */
 public function sendPasswordResetEmail($userId)
 {
     $timestamp = time();
     $usersTable = TableRegistry::get('Users');
     $hash = $usersTable->getPasswordResetHash($userId, $timestamp);
     $resetUrl = Router::url(['prefix' => false, 'controller' => 'Users', 'action' => 'resetPassword', $userId, $timestamp, $hash], true);
     $email = new Email('reset_password');
     $user = $usersTable->get($userId);
     $email->to($user->email);
     $email->viewVars(compact('user', 'resetUrl'));
     return $email->send();
 }
开发者ID:BallStateCBER,项目名称:cri,代码行数:19,代码来源:Mailer.php

示例10: register

 /**
  * Register method
  *
  * @return void Redirects on successful add, renders view otherwise.
  *                     */
 public function register()
 {
     $this->viewBuilder()->layout('registerv2');
     $user = $this->Users->newEntity();
     if ($this->request->is('post')) {
         if ($this->Recaptcha->verify()) {
             $user = $this->Users->patchEntity($user, $this->request->data);
             $user->email_validation_code = rand(10000, 99999);
             $user->role = 'student';
             if ($this->Users->save($user)) {
                 $email = new Email();
                 $email->template('confirmation')->emailFormat('text')->to($user->email)->from('egresados@tectijuana.edu.mx');
                 $validate_url = "http://www.egresadositt.com/users/validateEmail/{$user->id}/{$user->email_validation_code}";
                 $email->viewVars(['first_name' => $user->first_name, 'email_validation_code' => $validate_url, 'user_name' => $user->username]);
                 $email->send();
                 $this->Flash->success(__('The user has been saved.'));
                 return $this->redirect(['controller' => 'Pages', 'action' => 'success']);
             } else {
                 $this->Flash->error(__('The user could not be saved. Please, try again.'));
             }
         } else {
             $this->Flash->error(__('Please check your Recaptcha Box.'));
         }
     }
     $generations = $this->Users->Generations->find('list', ['limit' => 200]);
     $careers = $this->Users->Careers->find('list', ['limit' => 200]);
     $questions = $this->Users->Questions->find('list', ['limit' => 200]);
     $this->set(compact('user', 'generations', 'careers', 'questions'));
     $this->set('_serialize', ['user']);
 }
开发者ID:nerthux,项目名称:egresados,代码行数:35,代码来源:UsersController.php

示例11: forgot

 /**
  * Allow a user to request a password reset.
  * @return
  */
 function forgot()
 {
     header('Content-Type: application/json');
     header('Access-Control-Allow-Origin: *');
     $userInfo = TableRegistry::get('Users');
     $userDetails = TableRegistry::get('UserDetails');
     //print_r($_REQUEST);die();
     if ($this->request->query) {
         $user_email = $_REQUEST['email'];
         if (!empty($user_email)) {
             $users = $userInfo->find('all', ['conditions' => ['Users.email' => $user_email]]);
             $user = $users->first();
             $user_details = $userDetails->find('all', ['conditions' => ['UserDetails.user_id' => $user->id]]);
             $userInfo = $user_details->first();
             //echo $user->email;die;
             if (!$user) {
                 $mesg['msg'] = 'Sorry, the username entered was not found.';
                 $mesg['response_code'] = '0';
                 echo json_encode($mesg);
                 die;
             } else {
                 //Time::$defaultLocale = 'es-ES';
                 $link = BASE_SERVER_URL . 'logins/forgotpassform';
                 $time = Time::now('Asia/Kolkata');
                 $time_new = $time->i18nFormat('yyyy-MM-dd HH:mm:ss');
                 $token = $user->id . "+" . $user->email . "+" . $time_new;
                 $token_new = base64_encode($token);
                 //$email = new Email('mailjet');
                 $email = new Email();
                 $email->transport('mailjet');
                 $email->viewVars(['last_name' => $userInfo->lastname]);
                 $email->viewVars(['PASSWORD_RESET_LINK' => FORGOT_PAGE_LINK]);
                 $email->from(['himani.arora@sdnainfotech.com' => 'My Site'])->template('forgot', 'htmlemail')->emailFormat('html')->to($user->email)->subject('Forgot Password')->send();
                 if ($email) {
                     $mesg['msg'] = 'Mail send to your mail. Please check inbox.';
                     $mesg['response_code'] = '1';
                     echo json_encode($mesg);
                     die;
                 }
             }
         }
     }
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:47,代码来源:LoginsController.php

示例12: register


//.........这里部分代码省略.........
         die;
     }
     if (!preg_match('/^[a-z0-9A-Z]*$/', $password)) {
         $mesg['msg'] = 'The password that you have given is not valid.It should be alphanumeric.Please try again.';
         $mesg['response_code'] = '0';
         echo json_encode($mesg);
         die;
     }
     if (strlen($password) < 6) {
         $mesg['msg'] = 'Minimum 6 characters required for password.';
         $mesg['response_code'] = '0';
         echo json_encode($mesg);
         die;
     }
     if (!ctype_digit($telephoneno)) {
         $mesg['msg'] = 'Given telephone number is not a numeric.';
         $mesg['response_code'] = '0';
         echo json_encode($mesg);
         die;
     }
     if (strlen($telephoneno) > 20) {
         $mesg['msg'] = 'Maximum 20 characters can be used for telephone no.';
         $mesg['response_code'] = '0';
         echo json_encode($mesg);
         die;
     }
     if (!empty($fax_no)) {
         if (!ctype_digit($fax_no)) {
             $mesg['msg'] = 'Given fax number is not a numeric.';
             $mesg['response_code'] = '0';
             echo json_encode($mesg);
             die;
         }
         if (strlen($fax_no) > 20) {
             $mesg['msg'] = 'Maximum 20 characters can be used for fax no.';
             $mesg['response_code'] = '0';
             echo json_encode($mesg);
             die;
         }
     }
     $user = $this->Users->newEntity();
     $getArray = array('email' => $email, 'password' => $password, 'status' => '1');
     $user = $this->Users->patchEntity($user, $getArray);
     $query = $this->Users->find('all', ['conditions' => ['Users.email LIKE ' => '%' . $search . '%'], 'limit' => 1])->all();
     $counts = $query->count();
     if ($counts == '1') {
         //DUPLICATE MAIL CHECK
         $mesg['msg'] = 'The email already in use. Please, try again.';
         $mesg['response_code'] = '0';
         echo json_encode($mesg);
         die;
     }
     if ($this->Users->save($user)) {
         //print_r($user->id);
         $userAddress = TableRegistry::get('UserAddresses');
         $UserDetails = TableRegistry::get('UserDetails');
         $user_address = $userAddress->newEntity();
         $user_address->user_id = $user->id;
         $user_address->street_address = $street;
         //$user_address->country = $country;
         $user_address->country = 'Singapore';
         $user_address->postalcode = $postalcode;
         $user_address->telephone = $telephoneno;
         $user_address->fax_no = $fax_no;
         if ($userAddress->save($user_address)) {
             $userAddress_lastid = $user_address->id;
         }
         $User_details = $UserDetails->newEntity();
         $User_details->user_id = $user->id;
         $User_details->firstname = $fname;
         $User_details->lastname = $lname;
         $User_details->blockno = $blockno;
         $User_details->unitno = $unitno;
         $User_details->company = $compname;
         $User_details->position = $position;
         if ($UserDetails->save($User_details)) {
             //$User_details_lastid = $UserDetails->getLastInsertID();
         }
         //SEND EMAIL...............................
         //http://book.cakephp.org/3.0/en/core-libraries/email.html
         $emailer = new Email();
         $emailer->transport('mailjet');
         $emailer->viewVars(['last_name' => $lname]);
         //$emailto='deepak.rathi@sdnainfotech.com';
         $emailto = $email;
         try {
             $res = $emailer->from(['bls@admin.com'])->template('welcome', 'fancy')->emailFormat('html')->to([$emailto => 'BLS-New User'])->subject('Membership activation')->send('test-email...');
         } catch (Exception $e) {
             echo 'Exception : ', $e->getMessage(), "\n";
         }
         //----------------------------------------
         $mesg['msg'] = 'The user has been saved.';
         $mesg['response_code'] = '1';
     } else {
         $mesg['msg'] = 'The user could not be saved. Please, try again.';
         $mesg['response_code'] = '0';
     }
     echo json_encode($mesg);
     die;
 }
开发者ID:rashmi,项目名称:newrepo,代码行数:101,代码来源:UsersController.php

示例13: send

 /**
  * Send emails
  *
  * @param string $template
  * @param array $data
  * @param string $config
  * @throws SocketException if mail could not be sent
  */
 public function send($data = [], $template = 'default', $config = 'default')
 {
     // initialize class
     $email = new Email($config);
     // to?
     if (isset($data['to'])) {
         $email->to($data['to']);
     }
     // brand
     $from = $email->from();
     $brand = reset($from);
     // subject?
     $subject = isset($data['subject']) ? $data['subject'] : $email->subject();
     $email->subject(trim($config == 'debug' ? $brand . ' report: ' . $subject : $subject . ' - ' . $brand));
     // template?
     $email->template($template);
     // data & send
     $email->viewVars(['subject' => $subject, 'form' => isset($data['form']) ? $data['form'] : [], 'brand' => $brand, 'info' => ['ip' => $this->request->clientIP(), 'useragent' => env('HTTP_USER_AGENT'), 'date' => strftime('%d.%m.%Y %H:%M')]])->send();
 }
开发者ID:unimatrix,项目名称:cakephp-utility,代码行数:27,代码来源:EmailComponent.php


注:本文中的Cake\Mailer\Email::viewVars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。