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


PHP Mailer\Email类代码示例

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


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

示例1: send

 /**
  * Send email via Mailgun SDK
  *
  * @param Email $email
  * @return \stdClass $result containing status code and message
  * @throws Exception
  */
 public function send(Email $email)
 {
     $config = $email->profile();
     $email->domain($config['mailgun_domain']);
     $emailHeaders = ['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject', '_headers'];
     //'_headers' will include all extra tags that may be related to mailgun fields with prefix 'o:' or custom data with prefix 'v:'
     foreach ($email->getHeaders($emailHeaders) as $header => $value) {
         if (isset($this->ParamMapping[$header]) && !empty($value)) {
             //empty params are not excepted by mailgun, throws error
             $key = $this->ParamMapping[$header];
             $params[$key] = $value;
             continue;
         }
         if ($this->isDataCustom($header, $value)) {
             $params[$header] = $value;
         }
     }
     $params['html'] = $email->message(Email::MESSAGE_HTML);
     $params['text'] = $email->message(Email::MESSAGE_TEXT);
     $attachments = array();
     foreach ($email->attachments() as $name => $file) {
         $attachments['attachment'][] = ['filePath' => '@' . $file['file'], 'remoteName' => $name];
     }
     return $this->mailgun($config, $params, $attachments);
 }
开发者ID:motsmanish,项目名称:cakephp-mailgun,代码行数:32,代码来源:MailgunTransport.php

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

示例3: gmail

 public function gmail()
 {
     $email = new Email('gmail-profile');
     $email->emailFormat('html')->template('compra', 'default')->viewVars(['nombres' => 'Erick Benites', 'producto' => 'CakePHPCookbook'])->to('erick.benites@gmail.com')->subject('Correo desde CakePHP 3 con Gmail')->attachments(['CakePHPCookbook.pdf' => WWW_ROOT . 'CakePHPCookbook.pdf', 'photo.png' => ['file' => WWW_ROOT . 'img/logo.png', 'mimetype' => 'image/png', 'contentId' => 'logo-id']])->send("Contenido adicional ... \n ...");
     echo 'Correo enviado';
     $this->autoRender = false;
 }
开发者ID:ebenites,项目名称:cakephp,代码行数:7,代码来源:CorreoController.php

示例4: send

 public function send($to, $variables = [], $options = [])
 {
     $result = false;
     if (!isset($options['transport'])) {
         $options['transport'] = $this->config('transport');
     }
     if (!isset($options['emailFormat'])) {
         $options['emailFormat'] = $this->config('emailFormat');
     }
     if (Configure::read('Email.queue')) {
         if (isset($options['from'])) {
             $options['from_name'] = reset($options['from']);
             $options['from_email'] = key($options['from']);
             unset($options['from']);
         }
         EmailQueue::enqueue($to, $variables, $options);
         $result = true;
     } else {
         $options['to'] = $to;
         $options['viewVars'] = $variables;
         $email = new Email();
         $email->profile($options);
         $result = $email->send();
     }
     return $result;
 }
开发者ID:mindforce,项目名称:cakephp-platform,代码行数:26,代码来源:EmailComponent.php

示例5: send

 /**
  * Send mail
  *
  * @param \Cake\Mailer\Email $email Cake Email
  * @return array
  */
 public function send(Email $email)
 {
     $headers = $email->getHeaders(['from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject']);
     $headers = $this->_headersToString($headers);
     $message = implode("\r\n", (array) $email->message());
     return ['headers' => $headers, 'message' => $message];
 }
开发者ID:nrother,项目名称:cakephp,代码行数:13,代码来源:DebugTransport.php

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

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

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

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

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

示例11: _getEmailInstance

 /**
  * Get or initialize the email instance. Used for mocking.
  *
  * @param Email $email if email provided, we'll use the instance instead of creating a new one
  * @return Email
  */
 protected function _getEmailInstance(Email $email = null)
 {
     if ($email === null) {
         $email = new Email('default');
         $email->emailFormat('both');
     }
     return $email;
 }
开发者ID:drmonkeyninja,项目名称:users,代码行数:14,代码来源:Behavior.php

示例12: email

 /**
  * Creates an email instance overriding its transport for testing purposes.
  *
  * @param bool $new Tells if new instance should forcebly be created.
  * @return \Cake\Mailer\Email
  */
 public function email($new = false)
 {
     if ($new || !$this->_email) {
         $this->_email = new Email();
         $this->_email->profile(['transport' => 'debug'] + $this->_email->profile());
     }
     return $this->_email;
 }
开发者ID:nrother,项目名称:cakephp,代码行数:14,代码来源:EmailAssertTrait.php

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

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

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


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