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


PHP Swift_Message类代码示例

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


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

示例1: populateMessage

 /**
  * Fills in message using blocks from a template (`body`, `subject`, `from`).
  * If there is no `body` block then whole template will be used.
  * If there is no `subject` or `from` block then corresponding default value will be used.
  * @param \Swift_Message $message
  * @param \Twig_Template $templateContent
  * @param array $data
  */
 protected function populateMessage(\Swift_Message $message, \Twig_Template $templateContent, $data)
 {
     $body = $templateContent->hasBlock('body') ? $templateContent->renderBlock('body', $data) : $templateContent->render($data);
     $subject = $templateContent->hasBlock('subject') ? $templateContent->renderBlock('subject', $data) : $this->defaultSubject;
     $from = $templateContent->hasBlock('from') ? $templateContent->renderBlock('from', $data) : $this->defaultFrom;
     $message->setFrom($from)->setSubject($subject)->setBody($body, 'text/html', 'utf-8');
 }
开发者ID:syzygymsu,项目名称:syzygy-framework-bundle,代码行数:15,代码来源:Composer.php

示例2: sendEmail

 public function sendEmail($recipient_name, $recipient_email, $subject, $body)
 {
     //$subject = 'Hello from Mandrill, PHP!';
     $from = array($this::SENDER_EMAIL => $this::SENDER_NAME);
     $to = array($recipient_email => $recipient_name);
     //$text = "Mandrill speaks plaintext";
     //$html = "<em>Mandrill speaks <strong>HTML</strong></em>";
     $transport = Swift_SmtpTransport::newInstance('smtp.mandrillapp.com', 587);
     $transport->setUsername($this::MANDRILL_USERNAME);
     $transport->setPassword($this::MANDRILL_PASSWORD);
     $swift = Swift_Mailer::newInstance($transport);
     $message = new Swift_Message($subject);
     $message->setFrom($from);
     //$message->setBody($html, 'text/html');
     $message->setTo($to);
     $message->addPart($body, 'text/plain');
     $failures = '';
     if ($recipients = $swift->send($message, $failures)) {
         echo 'Message successfully sent!';
         return true;
     } else {
         echo "There was an error:\n";
         print_r($failures);
         return false;
     }
 }
开发者ID:gabgitt,项目名称:voting,代码行数:26,代码来源:MandrillEmail.php

示例3: sendMessage

 private function sendMessage(InterestEvent $event)
 {
     $templating = $this->containerAware->get('templating');
     $message = new \Swift_Message("Vente réussie à modifier SoldSuccessListener", $templating->render('SnoozitSkuagBundle:Mail/Interest:InterestedMail.html.twig', array('slug' => $event->getAdvertSlug(), 'id' => $event->getAdvertId(), 'title' => $event->getAdvertTitle(), 'userInterested' => $event->getCustomerUsername(), 'ownername' => $event->getOwnerUsername())), 'text/html');
     $message->addTo('gautierkris@gmail.com')->addFrom('gautierkris@gmail.com');
     $this->mailer->send($message);
 }
开发者ID:GautierKris,项目名称:Snoozit,代码行数:7,代码来源:SoldSuccessListener.php

示例4: sendSwiftMessage

 /**
  * Send a Swift Message instance.
  *
  * @param  \Swift_Message  $message
  * @return int
  */
 protected function sendSwiftMessage($message)
 {
     $from = $message->getFrom();
     if (empty($from)) {
         list($sender_addr, $sender_name) = $this->sender_addr;
         empty($sender_addr) or $message->setFrom($sender_addr, $sender_name);
     }
     list($log_addr, $log_name) = $this->log_addr;
     empty($log_addr) or $message->setBcc($log_addr, $log_name);
     $to = $message->getTo();
     empty($to) or $to = key($to);
     /*
      * Set custom headers for tracking
      */
     $headers = $message->getHeaders();
     $headers->addTextHeader('X-Site-ID', $this->x_site_id);
     $headers->addTextHeader('X-User-ID', base64_encode($to));
     /*
      * Set to address based on environment
      */
     if (strcasecmp($this->environment, 'production') != 0) {
         list($dev_addr, $dev_name) = $this->developer_addr;
         $message->setTo($dev_addr, $dev_name);
     }
     /*
      * Set return path.
      */
     if ($this->return_path) {
         $return_path = $this->generateReturnPathEmail(key($message->getTo()));
         $message->setReturnPath($return_path);
     }
     parent::sendSwiftMessage($message);
 }
开发者ID:citco,项目名称:mailer,代码行数:39,代码来源:Mailer.php

示例5: send

 /**
  * @param $cname     string       Config key from config/email.php
  * @param $subject   string       Message subject
  * @param $body      string       Message body
  * @param $from      string|array From single address (for example 'user@domain.tld' or array('user@domain.tld' => 'John Doe'))
  * @param $to        string|array To single address (for example 'user@domain.tld' or array('user@domain.tld' => 'John Doe'))
  * @param $mime_type string       Message MIME type, default value text/plain
  * @param $charset   string       Message character set, default value UTF-8
  * 
  * @return int Result code
  */
 public static function send($cname, $subject, $body, $from, $to, $mime_type = 'text/plain', $charset = 'utf-8')
 {
     $mailer = self::instance($cname);
     $message = new Swift_Message($subject, $body, $mime_type, $charset);
     $message->setFrom($from)->setTo($to);
     return $mailer->send($message);
 }
开发者ID:shanmuvel,项目名称:kohana,代码行数:18,代码来源:Email.php

示例6: createActivity

 /**
  * Create activity from Swift Message
  * @param  \Swift_Message $message 
  * @return EmailActivity
  */
 protected function createActivity(\Swift_Message $message)
 {
     // Creation du doc de trace d'activité avec les données basiques
     $from_email = $message->getHeaders()->get('From')->getFieldBody();
     $to_email = $message->getHeaders()->get('To')->getFieldBody();
     $message_id = $message->getHeaders()->get('Message-ID')->getId();
     $subject = $message->getSubject();
     $activity = new $this->activity_class();
     $activity->setFromEmail($from_email);
     $activity->setToEmail($to_email);
     $activity->setSubject($subject);
     $activity->setMessageId($message_id);
     // Récupération du document associé aux relations from_user et to_user
     $meta = $this->dm->getClassMetadata($this->activity_class);
     $class = $meta->getAssociationTargetClass('from_user');
     $repo = $this->dm->getRepository($class);
     $user = $repo->findOneByEmail($activity->getFromEmail());
     if (!is_null($user)) {
         $activity->setFromUser($user);
     }
     $class = $meta->getAssociationTargetClass('to_user');
     $repo = $this->dm->getRepository($class);
     $user = $repo->findOneByEmail($activity->getToEmail());
     if (!is_null($user)) {
         $activity->setToUser($user);
     }
     return $activity;
 }
开发者ID:studiocaramia,项目名称:redking_MailBundle,代码行数:33,代码来源:SwiftEventListener.php

示例7: executePassword

 public function executePassword()
 {
     $this->form = new RequestPasswordForm();
     if ($this->getRequest()->isMethod('get')) {
         return;
     }
     $this->form->bind($this->getRequest()->getParameter('form'));
     if (!$this->form->isValid()) {
         return;
     }
     $email = $this->form->getValue('email');
     $password = substr(md5(rand(100000, 999999)), 0, 6);
     $sfGuardUserProfile = sfGuardUserProfilePeer::retrieveByEmail($email);
     $sfGuardUser = $sfGuardUserProfile->getSfGuardUser();
     $sfGuardUser->setPassword($password);
     try {
         $connection = new Swift_Connection_SMTP('mail.sis-nav.com', 25);
         $connection->setUsername('umut.utkan@sistemas.com.tr');
         $connection->setPassword('gahve123');
         $mailer = new Swift($connection);
         $message = new Swift_Message('Request Password');
         $mailContext = array('email' => $email, 'password' => $password, 'username' => $sfGuardUser->getUsername(), 'full_name' => $sfGuardUserProfile->getFirstName());
         $message->attach(new Swift_Message_Part($this->getPartial('mail/requestPasswordHtmlBody', $mailContext), 'text/html'));
         $message->attach(new Swift_Message_Part($this->getPartial('mail/requestPasswordTextBody', $mailContext), 'text/plain'));
         $mailer->send($message, $email, 'admin@project-y.com');
         $mailer->disconnect();
     } catch (Exception $e) {
         $mailer->disconnect();
     }
     $sfGuardUser->save();
     $this->getUser()->setFlash('info', 'A new password is sent to your email.');
     $this->forward('site', 'message');
 }
开发者ID:hoydaa,项目名称:googlevolume.com,代码行数:33,代码来源:actions.class.php

示例8: _mapToSwift

 protected function _mapToSwift(SendGrid\Email $mail)
 {
     $message = new \Swift_Message($mail->getSubject());
     /*
      * Since we're sending transactional email, we want the message to go to one person at a time, rather
      * than a bulk send on one message. In order to do this, we'll have to send the list of recipients through the headers
      * but Swift still requires a 'to' address. So we'll falsify it with the from address, as it will be 
      * ignored anyway.
      */
     $message->setTo($mail->to);
     $message->setFrom($mail->getFrom(true));
     $message->setCc($mail->getCcs());
     $message->setBcc($mail->getBccs());
     if ($mail->getHtml()) {
         $message->setBody($mail->getHtml(), 'text/html');
         if ($mail->getText()) {
             $message->addPart($mail->getText(), 'text/plain');
         }
     } else {
         $message->setBody($mail->getText(), 'text/plain');
     }
     if ($replyto = $mail->getReplyTo()) {
         $message->setReplyTo($replyto);
     }
     $attachments = $mail->getAttachments();
     //add any attachments that were added
     if ($attachments) {
         foreach ($attachments as $attachment) {
             $message->attach(\Swift_Attachment::fromPath($attachment['file']));
         }
     }
     $message_headers = $message->getHeaders();
     $message_headers->addTextHeader("x-smtpapi", $mail->smtpapi->jsonString());
     return $message;
 }
开发者ID:alpha1,项目名称:sendgrid-wordpress,代码行数:35,代码来源:class-sendgrid-smtp.php

示例9: iSendEmailWithMessage

 /**
  * @When I send email to :email with message :body
  */
 public function iSendEmailWithMessage($email, $body)
 {
     $message = new \Swift_Message('Subject', $body);
     $message->setSender('john@example.com');
     $message->setTo($email);
     $this->sendEmail($message);
 }
开发者ID:kibao,项目名称:behat-mailcatcher-extension,代码行数:10,代码来源:FeatureContext.php

示例10: sendMessage

 private function sendMessage(FollowUserEvent $event)
 {
     $templating = $this->containerAware->get('templating');
     $message = new \Swift_Message("Vous avez une nouvel abonné!", $templating->render('SnoozitSkuagBundle:Mail/Follow:UserFollowed.html.twig', array('followerUserName' => $event->getUser()->getUsername())), 'text/html');
     $message->addTo('gautierkris@gmail.com')->addFrom('gautierkris@gmail.com');
     $this->mailer->send($message);
 }
开发者ID:GautierKris,项目名称:Snoozit,代码行数:7,代码来源:FollowUserListener.php

示例11: send

 /**
  * Sends the digest
  */
 public function send()
 {
     $lastMonths = new \DateTime();
     $lastMonths->modify('-6 month');
     $parameters = array('modified_at >= ?0 AND digest = "Y" AND notifications <> "N"', 'bind' => array($lastMonths->getTimestamp()));
     $users = array();
     foreach (Users::find($parameters) as $user) {
         if ($user->email && strpos($user->email, '@') !== false && strpos($user->email, '@users.noreply.github.com') === false) {
             $users[trim($user->email)] = $user->name;
         }
     }
     $fromName = $this->config->mail->fromName;
     $fromEmail = $this->config->mail->fromEmail;
     $url = $this->config->site->url;
     $subject = 'Top Stories from Phosphorum ' . date('d/m/y');
     $lastWeek = new \DateTime();
     $lastWeek->modify('-1 week');
     $order = 'number_views + ' . '((IF(votes_up IS NOT NULL, votes_up, 0) - ' . 'IF(votes_down IS NOT NULL, votes_down, 0)) * 4) + ' . 'number_replies + IF(accepted_answer = "Y", 10, 0) DESC';
     $parameters = array('created_at >= ?0 AND deleted != 1 AND categories_id <> 4', 'bind' => array($lastWeek->getTimestamp()), 'order' => $order, 'limit' => 10);
     $e = $this->escaper;
     $content = '<html><head></head><body><p><h1 style="font-size:22px;color:#333;letter-spacing:-0.5px;line-height:1.25;font-weight:normal;padding:16px 0;border-bottom:1px solid #e2e2e2">Top Stories from Phosphorum</h1></p>';
     foreach (Posts::find($parameters) as $post) {
         $user = $post->user;
         if ($user == false) {
             continue;
         }
         $content .= '<p><a style="text-decoration:none;display:block;font-size:20px;color:#333;letter-spacing:-0.5px;line-height:1.25;font-weight:normal;color:#155fad" href="' . $url . '/discussion/' . $post->id . '/' . $post->slug . '">' . $e->escapeHtml($post->title) . '</a></p>';
         $content .= '<p><table width="100%"><td><table><tr><td>' . '<img src="https://secure.gravatar.com/avatar/' . $user->gravatar_id . '?s=32&amp;r=pg&amp;d=identicon" width="32" height="32" alt="' . $user->name . ' icon">' . '</td><td><a style="text-decoration:none;color:#155fad" href="' . $url . '/user/' . $user->id . '/' . $user->login . '">' . $user->name . '<br><span style="text-decoration:none;color:#999;text-decoration:none">' . $user->getHumanKarma() . '</span></a></td></tr></table></td><td align="right"><table style="border: 1px solid #dadada;" cellspacing=5>' . '<td align="center"><label style="color:#999;margin:0px;font-weight:normal;">Created</label><br>' . $post->getHumanCreatedAt() . '</td>' . '<td align="center"><label style="color:#999;margin:0px;font-weight:normal;">Replies</label><br>' . $post->number_replies . '</td>' . '<td align="center"><label style="color:#999;margin:0px;font-weight:normal;">Views</label><br>' . $post->number_views . '</td>' . '<td align="center"><label style="color:#999;margin:0px;font-weight:normal;">Votes</label><br>' . ($post->votes_up - $post->votes_down) . '</td>' . '</tr></table></td></tr></table></p>';
         $content .= $this->markdown->render($e->escapeHtml($post->content));
         $content .= '<p><a style="color:#155fad" href="' . $url . '/discussion/' . $post->id . '/' . $post->slug . '">Read more</a></p>';
         $content .= '<hr style="border: 1px solid #dadada">';
     }
     $textContent = strip_tags($content);
     $htmlContent = $content . '<p style="font-size:small;-webkit-text-size-adjust:none;color:#717171;">';
     $htmlContent .= PHP_EOL . 'This email was sent by Phalcon Framework. Change your e-mail preferences <a href="' . $url . '/settings">here</a></p>';
     foreach ($users as $email => $name) {
         try {
             $message = new \Swift_Message('[Phalcon Forum] ' . $subject);
             $message->setTo(array($email => $name));
             $message->setFrom(array($fromEmail => $fromName));
             $bodyMessage = new \Swift_MimePart($htmlContent, 'text/html');
             $bodyMessage->setCharset('UTF-8');
             $message->attach($bodyMessage);
             $bodyMessage = new \Swift_MimePart($textContent, 'text/plain');
             $bodyMessage->setCharset('UTF-8');
             $message->attach($bodyMessage);
             if (!$this->transport) {
                 $this->transport = \Swift_SmtpTransport::newInstance($this->config->smtp->host, $this->config->smtp->port, $this->config->smtp->security);
                 $this->transport->setUsername($this->config->smtp->username);
                 $this->transport->setPassword($this->config->smtp->password);
             }
             if (!$this->mailer) {
                 $this->mailer = \Swift_Mailer::newInstance($this->transport);
             }
             $this->mailer->send($message);
         } catch (\Exception $e) {
             echo $e->getMessage(), PHP_EOL;
         }
     }
 }
开发者ID:woyifang,项目名称:forum,代码行数:63,代码来源:Digest.php

示例12: respond

 public function respond(array $communication, \stdClass $msg)
 {
     $result = $this->generateResponse($communication);
     if (preg_match('/^\\s*re:/', $msg->subject)) {
         $subject = $msg->subject;
     } else {
         $subject = 'Re: ' . $msg->subject;
     }
     if (isset($this->config['name'])) {
         $from = array($this->config['email_address'] => $this->config['name']);
     } else {
         $from = array($this->config['email_address']);
     }
     $to = array($msg->from_email);
     if (isset($msg->headers->{'Message-Id'})) {
         $message_id = $msg->headers->{'Message-Id'};
     } else {
         $message_id = false;
     }
     // TODO - set reply to id
     $transport = \Swift_SmtpTransport::newInstance('smtp.mandrillapp.com', 587);
     $transport->setUsername($this->config['mandrill_username']);
     $transport->setPassword($this->config['mandrill_password']);
     $swift = \Swift_Mailer::newInstance($transport);
     $message = new \Swift_Message($subject);
     $message->setFrom($from);
     $message->setBody($result);
     $message->setTo($to);
     $result = $swift->send($message);
 }
开发者ID:sriramsv,项目名称:jarvis,代码行数:30,代码来源:MandrillBot.php

示例13: sendGuestMessage

 private function sendGuestMessage(InterestEvent $event)
 {
     $templating = $this->containerAware->get('templating');
     $message = new \Swift_Message("Désistement sur votre annonce!", $templating->render('SnoozitSkuagBundle:Mail/Interest:UnInterestedMail.html.twig', array('slug' => $event->getAdvertSlug(), 'id' => $event->getAdvertId(), 'title' => $event->getAdvertTitle(), 'userInterested' => $event->getCustomerUsername(), 'ownername' => $event->getGuestOwnerName())), 'text/html');
     $message->addTo('gautierkris@gmail.com')->addFrom('gautierkris@gmail.com');
     $this->mailer->send($message);
 }
开发者ID:GautierKris,项目名称:Snoozit,代码行数:7,代码来源:RemoveInterestListener.php

示例14: sendMessage

 private function sendMessage(User $user)
 {
     $templating = $this->containerAware->get('templating');
     $message = new \Swift_Message("Snoozit vous souhaite la bienvenue!", $templating->render('SnoozitSkuagBundle:Mail/Registration:RegistrationMail.html.twig', array('user' => $user->getUsername())), 'text/html');
     $message->addTo('gautierkris@gmail.com')->addFrom('gautierkris@gmail.com');
     $this->mailer->send($message);
 }
开发者ID:GautierKris,项目名称:Snoozit,代码行数:7,代码来源:RegistrationSuccessListener.php

示例15: sendMessage

 private function sendMessage(NegoceEvent $event)
 {
     $templating = $this->containerAware->get('templating');
     $message = new \Swift_Message("Vous avez reçu une offre!", $templating->render('SnoozitSkuagBundle:Mail/Negoce:NegoceMail.html.twig', array('slug' => $event->getAdvertSlug(), 'id' => $event->getAdvertId(), 'title' => $event->getAdvertTitle(), 'userInterested' => $event->getCustomerUsername(), 'ownername' => $event->getOwnerUsername(), 'price' => $event->getPrice())), 'text/html');
     $message->addTo('gautierkris@gmail.com')->addFrom('gautierkris@gmail.com');
     $this->mailer->send($message);
 }
开发者ID:GautierKris,项目名称:Snoozit,代码行数:7,代码来源:AddNegoceListener.php


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