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


PHP Email::from方法代码示例

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


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

示例1: add

 public function add()
 {
     $user = $this->Users->newEntity();
     if ($this->request->is('post')) {
         $user = $this->Users->patchEntity($user, $this->request->data);
         if ($this->Users->save($user)) {
             $this->Flash->success(__("L'utilisateur a été sauvegardé."));
             $email = new Email('gmail');
             $email->from(['johei1337@gmail.com' => 'LeBonCoup'])->emailFormat('html')->to($user->email)->subject('Welcome ' . $user->prenom)->send('Bienvenu sur le site LeBonCoup,
                         <br>
                         Vous avez bien été enregistré sur le LeBonCoup
                         <br>
                         Votre nom utilisateur est: ' . $user->username . ' 
                         <br>
                         Cliquez sur ce lien pour valider votre compte <a href="http://comdfran.fr/leboncoup/users/validatemail/' . $user->email . '">validation</a>
                         <br>
                         Copier coller dans votre navigateur http://comdfran.fr/leboncoup/users/validatemail/' . $user->email . '
                         <br>
                         Cordialement,');
             return $this->redirect(['controller' => 'Pages', 'action' => 'display', 'home']);
         }
         $this->Flash->error(__("Impossible d'ajouter l'utilisateur."));
     }
     $this->set('user', $user);
 }
开发者ID:JoHein,项目名称:LeBonCoup,代码行数:25,代码来源:UsersController.php

示例2: _execute

 protected function _execute(array $data)
 {
     $email = new Email();
     $email->profile('default');
     $email->from([$data['email']])->to('ken.kitchen@gmail.com')->subject('Web Site Contact Form')->send([$data['body']]);
     return true;
 }
开发者ID:kenkitchen,项目名称:cakehrms-tutorial,代码行数:7,代码来源:ContactForm.php

示例3: send

 /**
  * Send mail
  *
  * @param \Cake\Mailer\Email $email Email instance.
  * @return array
  */
 public function send(Email $email)
 {
     $this->transportConfig = Hash::merge($this->transportConfig, $this->_config);
     $message = ['html' => $email->message(Email::MESSAGE_HTML), 'text' => $email->message(Email::MESSAGE_TEXT), 'subject' => mb_decode_mimeheader($email->subject()), 'from' => key($email->from()), 'fromname' => current($email->from()), 'to' => [], 'toname' => [], 'cc' => [], 'ccname' => [], 'bcc' => [], 'bccname' => [], 'replyto' => array_keys($email->replyTo())[0]];
     // Add receipients
     foreach (['to', 'cc', 'bcc'] as $type) {
         foreach ($email->{$type}() as $mail => $name) {
             $message[$type][] = $mail;
             $message[$type . 'name'][] = $name;
         }
     }
     // Create a new scoped Http Client
     $this->http = new Client(['host' => 'api.sendgrid.com', 'scheme' => 'https', 'headers' => ['User-Agent' => 'CakePHP SendGrid Plugin']]);
     $message = $this->_attachments($email, $message);
     return $this->_send($message);
 }
开发者ID:iandenh,项目名称:cakephp-sendgrid,代码行数:22,代码来源:SendgridTransport.php

示例4: display

 /**
  * Displays a view
  *
  * @return void|\Cake\Network\Response
  * @throws \Cake\Network\Exception\NotFoundException When the view file could not
  *   be found or \Cake\View\Exception\MissingTemplateException in debug mode.
  */
 public function display()
 {
     $path = func_get_args();
     $count = count($path);
     if (!$count) {
         return $this->redirect('/');
     }
     $page = $subpage = null;
     if (!empty($path[0])) {
         $page = $path[0];
     }
     if (!empty($path[1])) {
         $subpage = $path[1];
     }
     $this->set(compact('page', 'subpage'));
     try {
         $this->render(implode('/', $path));
     } catch (MissingTemplateException $e) {
         if (Configure::read('debug')) {
             throw $e;
         }
         throw new NotFoundException();
     }
     // Contact Form
     if ($this->request->is('post')) {
         $email = new Email();
         $email->from(['me@example.com' => 'My Site'])->to('sharehyip@gmail.com')->subject('About')->send('My message');
         $this->Flash->success(__('The request has been saved.'));
     }
 }
开发者ID:vanhoanweb,项目名称:lister,代码行数:37,代码来源:PagesController.php

示例5: preview

 public function preview($e)
 {
     $configName = $e['config'];
     $template = $e['template'];
     $layout = $e['layout'];
     $headers = empty($e['headers']) ? [] : (array) $e['headers'];
     $theme = empty($e['theme']) ? '' : (string) $e['theme'];
     $email = new Email($configName);
     if (!empty($e['attachments'])) {
         $email->attachments($e['attachments']);
     }
     $email->transport('Debug')->to($e['email'])->subject($e['subject'])->template($template, $layout)->emailFormat($e['format'])->addHeaders($headers)->theme($theme)->messageId(false)->returnPath($email->from())->viewVars($e['template_vars']);
     $return = $email->send();
     $this->out('Content:');
     $this->hr();
     $this->out($return['message']);
     $this->hr();
     $this->out('Headers:');
     $this->hr();
     $this->out($return['headers']);
     $this->hr();
     $this->out('Data:');
     $this->hr();
     debug($e['template_vars']);
     $this->hr();
     $this->out();
 }
开发者ID:lorenzo,项目名称:cakephp-email-queue,代码行数:27,代码来源:PreviewShell.php

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

示例7: smtp

 public function smtp()
 {
     $email = new Email('default');
     $email->from(['tienda@tecsup.edu.pe' => 'Tienda Online'])->to('erick.benites@gmail.com')->subject('Correo desde CakePHP 3')->send('Contenido del correo ...');
     echo 'Correo enviado';
     $this->autoRender = false;
 }
开发者ID:ebenites,项目名称:cakephp,代码行数:7,代码来源:CorreoController.php

示例8: testInvalidConfig

 /**
  * Test configuration
  *
  * @return void
  */
 public function testInvalidConfig()
 {
     $this->setExpectedException('SparkPostEmail\\Mailer\\Exception\\MissingCredentialsException');
     $this->SparkPostTransport->config($this->invalidConfig);
     $email = new Email();
     $email->transport($this->SparkPostTransport);
     $email->from(['support@sparkpostbox.com' => 'CakePHP SparkPost'])->to('test@sparkpostbox.com')->subject('This is test subject')->emailFormat('text')->send('Testing Maingun');
 }
开发者ID:narendravaghela,项目名称:cakephp-sparkpost,代码行数:13,代码来源:SparkPostTransportTest.php

示例9: _execute

 protected function _execute(array $data)
 {
     // Send an email.
     Email::configTransport('amazon', ['host' => 'email-smtp.us-east-1.amazonaws.com', 'port' => 587, 'username' => 'AKIAJARRU5LPFHEQHKPQ', 'password' => 'AmNFFJsVG8vQGHqlXgy9nMYj9eAx2ubZ/Ghb84FVm7PC', 'className' => 'Smtp', 'tls' => true]);
     $email = new Email('default');
     $email->from(['me@example.com' => 'My Site'])->to('zach@crystalclearfiber.com')->subject('About')->send('My message');
     return true;
 }
开发者ID:CrystalClearFiber,项目名称:site,代码行数:8,代码来源:ContactForm.php

示例10: sendEmailAfterEnroll

 private function sendEmailAfterEnroll($name, $email)
 {
     $message = 'Olá, ' . $name . '<br /><br />';
     $message .= 'Ficamos muito felizes por sua participação no sorteio da inscrição Silver para o PHP Conference Brasil.<br />';
     $message .= 'Acompanhe-nos pelo site <a href="http://phppr.net">http://phppr.net</a> para acompanhar nosso trabalho e ficar sabendo mais informações a respeito deste sorteio.<br />';
     $message .= '<br />Desde já lhe desejamos BOA SORTE!!!';
     $mailer = new Email('default');
     $mailer->from(['no-reply@phppr.net' => 'PHP PR'])->to($email, $name)->subject('Sorteio PHP PR')->emailFormat('html')->send($message);
 }
开发者ID:php-pr,项目名称:sorteio-php-conference,代码行数:9,代码来源:ParticipantesController.php

示例11: passwordChangedEmail

 /**
  * @param $data
  */
 public function passwordChangedEmail($data)
 {
     $app = new AppController();
     $subject = 'Password Changed - ' . $app->appsName;
     $email = new Email('mandril');
     $user = array('to' => $data['username'], 'name' => $data['profile']['first_name'] . ' ' . $data['profile']['last_name']);
     $data = array('user' => $user, 'appName' => $app->appsName);
     $email->from([$app->emailFrom => $app->appsName])->to($user['to'])->subject($subject)->theme($app->currentTheme)->template('changed_password')->emailFormat('html')->set(['data' => $data])->send();
 }
开发者ID:sohelrana820,项目名称:bookmark,代码行数:12,代码来源:UtilitiesComponent.php

示例12: _execute

 protected function _execute(array $data)
 {
     $email = new Email('default');
     $email->from(['entec.ifpe.igarassu@gmail.com' => 'EnTec 2016'])->emailFormat('html')->replyTo('entec.ifpe.igarassu@gmail.com', 'EnTec 2016')->subject('[EntTec 2016] ' . $data['assunto']);
     $destinatarios = $data['destinatarios'];
     for ($i = 0, $c = count($destinatarios); $i < $c; $i++) {
         $email->addBcc($destinatarios[$i]['email'], $destinatarios[$i]['nome']);
     }
     $email->send($data['corpo']);
     return true;
 }
开发者ID:AlexandreSGV,项目名称:siteentec,代码行数:11,代码来源:EmailForm.php

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

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

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


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