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


PHP Email::to方法代码示例

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


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

示例1: setupEmail

 protected function setupEmail(Email $email)
 {
     $this->sendgridEmail = new \SendGrid\Email();
     foreach ($email->to() as $e => $n) {
         $this->sendgridEmail->addTo($e, $n);
     }
     foreach ($email->cc() as $e => $n) {
         $this->sendgridEmail->addCc($e, $n);
     }
     foreach ($email->bcc() as $e => $n) {
         $this->sendgridEmail->addBcc($e, $n);
     }
     foreach ($email->from() as $e => $n) {
         $this->sendgridEmail->setFrom($e);
         $this->sendgridEmail->setFromName($n);
     }
     $this->sendgridEmail->setSubject($email->subject());
     $this->sendgridEmail->setText($email->message(Email::MESSAGE_TEXT));
     $this->sendgridEmail->setHtml($email->message(Email::MESSAGE_HTML));
     if ($email->attachments()) {
         foreach ($email->attachments() as $attachment) {
             $this->sendgridEmail->setAttachment($attachment['file'], $attachment['custom_filename']);
         }
     }
 }
开发者ID:madalinignisca,项目名称:sendgrid,代码行数:25,代码来源:SendgridTransport.php

示例2: testMissingRequiredFields

 /**
  * Test required fields
  *
  * @return void
  */
 public function testMissingRequiredFields()
 {
     $this->setExpectedException('BadMethodCallException');
     $this->SparkPostTransport->config($this->validConfig);
     $email = new Email();
     $email->transport($this->SparkPostTransport);
     $email->to('test@sparkpostbox.com')->subject('This is test subject')->emailFormat('text')->send('Testing Maingun');
 }
开发者ID:narendravaghela,项目名称:cakephp-sparkpost,代码行数:13,代码来源:SparkPostTransportTest.php

示例3: 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

示例4: testSendWithEmail

 /**
  * TestSend method
  *
  * @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['jobtype']);
     $this->assertTrue(strlen($result['data']) < 10000);
     $output = unserialize($result['data']);
     $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());
     //debug($output);
     //$this->assertEquals($Email, $output['settings']);
 }
开发者ID:alexandreanfilo,项目名称:cakephp-queue,代码行数:56,代码来源:SimpleQueueTransportTest.php

示例5: add

 /**
  * Add method
  *
  * @return void Redirects on successful add, renders view otherwise.
  */
 public function add()
 {
     $correo = $this->Correos->newEntity();
     if ($this->request->is('post')) {
         $correo = $this->Correos->patchEntity($correo, $this->request->data);
         $email = new Email('default');
         $email->to($this->request->data('destinario'))->subject($this->request->data('asunto'))->send($this->request->data('mensaje'));
         if ($this->Correos->save($correo)) {
             $this->Flash->success(__('The correo has been saved.'));
             return $this->redirect(['action' => 'index']);
         } else {
             $this->Flash->error(__('The correo could not be saved. Please, try again.'));
         }
     }
     $this->set(compact('correo'));
     $this->set('_serialize', ['correo']);
 }
开发者ID:esmar,项目名称:cakephp,代码行数:22,代码来源:CorreosController.php

示例6: testSendWithEmail

 /**
  * TestSend method
  *
  * @return void
  */
 public function testSendWithEmail()
 {
     $Email = new Email();
     $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->transport('queue');
     $config = $Email->config('default');
     $this->QueueTransport->config($config);
     $result = $this->QueueTransport->send($Email);
     $this->assertEquals('Email', $result['job_type']);
     $this->assertTrue(strlen($result['data']) < 10000);
     $output = json_decode($result['data'], true);
     $this->assertEquals('Testing Message', $output['settings']['_subject']);
 }
开发者ID:dereuromark,项目名称:cakephp-queue,代码行数:22,代码来源:QueueTransportTest.php

示例7: _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

示例8: 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

示例9: 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' => method_exists($email, 'getOriginalSubject') ? [$email->getOriginalSubject()] : [$email->subject()], '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]);
         }
     }
     $QueuedJobs = $this->getQueuedJobsModel();
     $result = $QueuedJobs->createJob('Email', ['settings' => $settings]);
     $result['headers'] = '';
     $result['message'] = '';
     return $result;
 }
开发者ID:dereuromark,项目名称:cakephp-queue,代码行数:25,代码来源:SimpleQueueTransport.php

示例10: 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

示例11: send

 /**
  * Send mail via SparkPost REST API
  *
  * @param \Cake\Mailer\Email $email Email message
  * @return array
  */
 public function send(Email $email)
 {
     // Load SparkPost configuration settings
     $apiKey = $this->config('apiKey');
     // Set up HTTP request adapter
     $adapter = new CakeHttpAdapter(new Client());
     // Create SparkPost API accessor
     $sparkpost = new SparkPost($adapter, ['key' => $apiKey]);
     // Pre-process CakePHP email object fields
     $from = (array) $email->from();
     $sender = sprintf('%s <%s>', mb_encode_mimeheader(array_values($from)[0]), array_keys($from)[0]);
     $to = (array) $email->to();
     $recipients = [['address' => ['name' => mb_encode_mimeheader(array_values($to)[0]), 'email' => array_keys($to)[0]]]];
     // Build message to send
     $message = ['from' => $sender, 'html' => empty($email->message('html')) ? $email->message('text') : $email->message('html'), 'text' => $email->message('text'), 'subject' => mb_decode_mimeheader($email->subject()), 'recipients' => $recipients];
     // Send message
     try {
         $sparkpost->transmission->send($message);
     } catch (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()));
     }
 }
开发者ID:syntaxera,项目名称:cakephp-sparkpost-plugin,代码行数:29,代码来源:SparkPostTransport.php

示例12: 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

示例13: testGetLastResponse

 /**
  * testGetLastResponse method
  *
  * @return void
  */
 public function testGetLastResponse()
 {
     $this->assertEmpty($this->SmtpTransport->getLastResponse());
     $this->socket->expects($this->any())->method('connect')->will($this->returnValue(true));
     $this->socket->expects($this->at(0))->method('read')->will($this->returnValue(false));
     $this->socket->expects($this->at(1))->method('read')->will($this->returnValue("220 Welcome message\r\n"));
     $this->socket->expects($this->at(2))->method('write')->with("EHLO localhost\r\n");
     $this->socket->expects($this->at(3))->method('read')->will($this->returnValue(false));
     $this->socket->expects($this->at(4))->method('read')->will($this->returnValue("250-PIPELINING\r\n"));
     $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250-SIZE 102400000\r\n"));
     $this->socket->expects($this->at(6))->method('read')->will($this->returnValue("250-VRFY\r\n"));
     $this->socket->expects($this->at(7))->method('read')->will($this->returnValue("250-ETRN\r\n"));
     $this->socket->expects($this->at(8))->method('read')->will($this->returnValue("250-STARTTLS\r\n"));
     $this->socket->expects($this->at(9))->method('read')->will($this->returnValue("250-AUTH PLAIN LOGIN\r\n"));
     $this->socket->expects($this->at(10))->method('read')->will($this->returnValue("250-AUTH=PLAIN LOGIN\r\n"));
     $this->socket->expects($this->at(11))->method('read')->will($this->returnValue("250-ENHANCEDSTATUSCODES\r\n"));
     $this->socket->expects($this->at(12))->method('read')->will($this->returnValue("250-8BITMIME\r\n"));
     $this->socket->expects($this->at(13))->method('read')->will($this->returnValue("250 DSN\r\n"));
     $this->SmtpTransport->connect();
     $expected = [['code' => '250', 'message' => 'PIPELINING'], ['code' => '250', 'message' => 'SIZE 102400000'], ['code' => '250', 'message' => 'VRFY'], ['code' => '250', 'message' => 'ETRN'], ['code' => '250', 'message' => 'STARTTLS'], ['code' => '250', 'message' => 'AUTH PLAIN LOGIN'], ['code' => '250', 'message' => 'AUTH=PLAIN LOGIN'], ['code' => '250', 'message' => 'ENHANCEDSTATUSCODES'], ['code' => '250', 'message' => '8BITMIME'], ['code' => '250', 'message' => 'DSN']];
     $result = $this->SmtpTransport->getLastResponse();
     $this->assertEquals($expected, $result);
     $email = new Email();
     $email->from('noreply@cakephp.org', 'CakePHP Test');
     $email->to('cake@cakephp.org', 'CakePHP');
     $this->socket->expects($this->at(0))->method('write')->with("MAIL FROM:<noreply@cakephp.org>\r\n");
     $this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
     $this->socket->expects($this->at(2))->method('read')->will($this->returnValue("250 OK\r\n"));
     $this->socket->expects($this->at(3))->method('write')->with("RCPT TO:<cake@cakephp.org>\r\n");
     $this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false));
     $this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250 OK\r\n"));
     $this->SmtpTransport->sendRcpt($email);
     $expected = [['code' => '250', 'message' => 'OK']];
     $result = $this->SmtpTransport->getLastResponse();
     $this->assertEquals($expected, $result);
 }
开发者ID:Slayug,项目名称:castor,代码行数:41,代码来源:SmtpTransportTest.php

示例14: 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

示例15: getEmailInstance

 /**
  * Builds an instance of the Email object with some default settings applied
  * from the model data.
  *
  * @return \Cake\Mailer\Email
  */
 private function getEmailInstance()
 {
     $email = new Email();
     $email->to($this->email)->viewVars(['key' => $this->personal_key])->emailFormat('both');
     return $email;
 }
开发者ID:propellerstudios,项目名称:users-plugin,代码行数:12,代码来源:User.php


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