當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Swift_Mailer::getTransport方法代碼示例

本文整理匯總了PHP中Swift_Mailer::getTransport方法的典型用法代碼示例。如果您正苦於以下問題:PHP Swift_Mailer::getTransport方法的具體用法?PHP Swift_Mailer::getTransport怎麽用?PHP Swift_Mailer::getTransport使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Swift_Mailer的用法示例。


在下文中一共展示了Swift_Mailer::getTransport方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: deliver

 /**
  * Delivers an email
  *
  * @param  MailInterface $mail
  * @param  Boolean       $readReceipt
  * @return int           the number of messages that have been sent
  *
  * @throws LogicException In case no Receiver provided
  * @throws LogicException In case a read-receipt is asked but no Emitter provided
  */
 public function deliver(MailInterface $mail, $readReceipt = false, array $attachments = null)
 {
     if (!$mail->getReceiver()) {
         throw new LogicException('You must provide a receiver for a mail notification');
     }
     $message = \Swift_Message::newInstance($this->prefix . $mail->getSubject(), $mail->renderHTML(), 'text/html', 'utf-8');
     $message->addPart($mail->getMessage(), 'text/plain', 'utf-8');
     $message->setFrom($this->emitter->getEmail(), $this->emitter->getName());
     $message->setTo($mail->getReceiver()->getEmail(), $mail->getReceiver()->getName());
     if ($mail->getEmitter()) {
         $message->setReplyTo($mail->getEmitter()->getEmail(), $mail->getEmitter()->getName());
     }
     if (is_array($attachments)) {
         foreach ($attachments as $attachment) {
             $message->attach($attachment->As_Swift_Attachment());
         }
     }
     if ($readReceipt) {
         if (!$mail->getEmitter()) {
             throw new LogicException('You must provide an emitter for a ReadReceipt');
         }
         $message->setReadReceiptTo([$mail->getEmitter()->getEmail() => $mail->getEmitter()->getName()]);
     }
     if (!$this->mailer->getTransport()->isStarted()) {
         $this->mailer->getTransport()->start();
     }
     $ret = $this->mailer->send($message);
     $this->mailer->getTransport()->stop();
     $this->dispatcher->dispatch('phraseanet.notification.sent');
     return $ret;
 }
開發者ID:luisbrito,項目名稱:Phraseanet,代碼行數:41,代碼來源:Deliverer.php

示例2: __construct

 /**
  * Create a new Message.
  *
  * @param string $name
  */
 public function __construct(string $name = null)
 {
     $this->mailer = self::mailer($name);
     if (!self::$listener) {
         self::$listener = new Listener();
         $this->mailer->getTransport()->registerPlugin(self::$listener);
     }
     $this->message = new \Swift_Message();
 }
開發者ID:cawaphp,項目名稱:email,代碼行數:14,代碼來源:Message.php

示例3: postTask

 public function postTask(Worker $worker, array $options = null)
 {
     if ($worker instanceof MailerAwareWorker) {
         if ($this->mailer && $this->transport) {
             //Flush the mailer queue, this isn't normally done until the command execution finishes
             $this->mailer->getTransport()->getSpool()->flushQueue($this->transport);
             $this->transport->stop();
             $this->logger->info('Flushed mail queue');
         }
     }
 }
開發者ID:mcfedr,項目名稱:job-manager-bundle,代碼行數:11,代碼來源:MailerListener.php

示例4: _flushEmailer

 private function _flushEmailer()
 {
     $transport = $this->_mailer->getTransport();
     if (!$transport instanceof \Swift_Transport_SpoolTransport) {
         return;
     }
     $spool = $transport->getSpool();
     if (!$spool instanceof \Swift_MemorySpool) {
         return;
     }
     $spool->flushQueue($this->_transport);
 }
開發者ID:ehough,項目名稱:emailerrors-bundle,代碼行數:12,代碼來源:Mailer.php

示例5: send

 /**
  * Sends a mail.
  *
  * @ParamType("message", type="Abc\Bundle\JobBundle\Job\Mailer\Message")
  * @ParamType("logger", type="@abc.logger")
  *
  * @param Message         $message
  * @param LoggerInterface $logger
  * @throws \Exception Rethrows exceptions thrown by mailer
  */
 public function send(Message $message, LoggerInterface $logger)
 {
     $logger->debug('Send mail {message}', array('message' => $message));
     $mail = $this->mailer->createMessage()->setSubject($message->getSubject())->setFrom($message->getFrom())->setTo($message->getTo());
     $mail->addPart($message->getMessage(), 'text/plain');
     try {
         $this->mailer->send($mail);
         $this->mailer->getTransport()->stop();
     } catch (\Exception $e) {
         $this->mailer->getTransport()->stop();
         throw $e;
     }
 }
開發者ID:aboutcoders,項目名稱:job-bundle,代碼行數:23,代碼來源:Mailer.php

示例6: __construct

 /**
  * Constructor
  *
  * @param \Swift_Mailer      $baseMailer
  * @param ContainerInterface $container
  */
 public function __construct(\Swift_Mailer $baseMailer, ContainerInterface $container)
 {
     $this->baseMailer = $baseMailer;
     $this->container = $container;
     $transport = $this->baseMailer->getTransport();
     if ($transport instanceof \Swift_Transport_SpoolTransport) {
         $transport = $this->findRealTransport();
         if (!$transport) {
             $transport = \Swift_NullTransport::newInstance();
         }
     }
     parent::__construct($transport);
 }
開發者ID:xamin123,項目名稱:platform,代碼行數:19,代碼來源:DirectMailer.php

示例7: process

 /**
  * {@inheritdoc}
  */
 public function process(ConsumerEvent $event)
 {
     if (!$this->mailer->getTransport()->isStarted()) {
         $this->mailer->getTransport()->start();
     }
     $exception = false;
     try {
         $this->sendEmail($event->getMessage());
     } catch (\Exception $e) {
         $exception = $e;
     }
     $this->mailer->getTransport()->stop();
     if ($exception) {
         throw new $exception();
     }
 }
開發者ID:rubenrua,項目名稱:SonataNotificationBundle,代碼行數:19,代碼來源:SwiftMailerConsumer.php

示例8: getTransport

 /**
  * The Transport used to send messages.
  *
  * @return \Swift_Transport|\Swift_SmtpTransport
  */
 public function getTransport()
 {
     if ($this->smtpTransport) {
         return $this->smtpTransport;
     }
     return parent::getTransport();
 }
開發者ID:ramunasd,項目名稱:platform,代碼行數:12,代碼來源:DirectMailer.php

示例9: sendSwiftMessage

 /**
  * Send a Swift Message instance.
  *
  * @param \Swift_Mime_Message $message
  *
  * @return int
  */
 protected function sendSwiftMessage(Swift_Mime_Message $message) : int
 {
     if ($this->events) {
         $this->events->trigger('events.message.sending', [$message]);
     }
     try {
         return $this->swift->send($message, $this->failedRecipients);
     } finally {
         $this->swift->getTransport()->stop();
     }
 }
開發者ID:narrowspark,項目名稱:framework,代碼行數:18,代碼來源:Mailer.php

示例10: sendSwiftMessage

 /**
  * Send a Swift Message instance.
  *
  * @param  \Swift_Message  $message
  * @return void
  */
 protected function sendSwiftMessage($message)
 {
     if ($this->events) {
         $this->events->fire(new Events\MessageSending($message));
     }
     try {
         return $this->swift->send($message, $this->failedRecipients);
     } finally {
         $this->swift->getTransport()->stop();
     }
 }
開發者ID:davidhemphill,項目名稱:framework,代碼行數:17,代碼來源:Mailer.php

示例11: sendBatchMail

 /**
  * @param $fromEmail
  * @param BatchEntryMail $batchMail
  * @param $doSend
  */
 private function sendBatchMail($fromEmail, BatchEntryMail $batchMail, $doSend)
 {
     $receivers = $batchMail->getReceiverEntries($this->em);
     $this->writeOutput('Sending "' . $batchMail->getName() . '" mail to ' . count($receivers) . ' people from ' . $fromEmail);
     $spool = $this->mailer->getTransport()->getSpool();
     foreach ($receivers as $receiver) {
         $this->writeOutput(' -> ' . $receiver->getEmail());
         $htmlTemplate = $batchMail->getHtmlTemplate($receiver);
         $plainTextTemplate = $batchMail->getPlainTextTemplate($receiver);
         $templateData = $batchMail->getTemplateData($receiver, $this->em);
         $this->translator->setLocale($receiver->getPool()->getLocale());
         $plainTextBody = $this->twig->render($plainTextTemplate, $templateData);
         $htmlBody = $this->twig->render($htmlTemplate, $templateData);
         $message = \Swift_Message::newInstance()->setSubject($batchMail->getSubject($receiver, $this->translator))->setFrom($fromEmail, $batchMail->getFrom($receiver, $this->translator))->setTo($receiver->getEmail())->setBody($plainTextBody)->addPart($htmlBody, 'text/html');
         if ($doSend) {
             $this->mailer->send($message);
             $spool->flushQueue($this->transport);
             $batchMail->handleMailSent($receiver, $this->em);
         }
     }
 }
開發者ID:vincecore,項目名稱:SecretSanta,代碼行數:26,代碼來源:Mailer.php

示例12: forceFlushForCommand

 /**
  * Force l'envoi des mails en mode Command
  * @return integer Number of emails sent
  */
 public function forceFlushForCommand()
 {
     // L'envoi des emails est déclenché sur une réponse du Kernel (inactif en mode commande)
     $transport = $this->swift->getTransport();
     if (!$transport instanceof \Swift_Transport_SpoolTransport) {
         return;
     }
     $spool = $transport->getSpool();
     if (!$spool instanceof \Swift_MemorySpool) {
         return;
     }
     return $spool->flushQueue($this->mailerRealTransport);
 }
開發者ID:alterphp,項目名稱:components,代碼行數:17,代碼來源:Mailer.php

示例13: modifySmtpSettings

 /**
  * Modify transport smtp settings
  *
  * @param UserEmailOrigin $userEmailOrigin
  */
 protected function modifySmtpSettings(UserEmailOrigin $userEmailOrigin)
 {
     $transport = $this->mailer->getTransport();
     if ($transport instanceof \Swift_Transport_EsmtpTransport) {
         $transport->setHost($userEmailOrigin->getSmtpHost());
         $transport->setPort($userEmailOrigin->getSmtpPort());
         $transport->setUsername($userEmailOrigin->getUser());
         $transport->setPassword($this->encryptor->decryptData($userEmailOrigin->getPassword()));
         if ($userEmailOrigin->getSmtpEncryption()) {
             $transport->setEncryption($userEmailOrigin->getSmtpEncryption());
         }
     }
 }
開發者ID:northdakota,項目名稱:platform,代碼行數:18,代碼來源:Processor.php

示例14: sendSwiftMessage

 /**
  * Send a Swift Message instance.
  *
  * @param  \Swift_Message  $message
  * @return void
  */
 protected function sendSwiftMessage($message)
 {
     if ($this->events) {
         $this->events->fire('mailer.sending', [$message]);
     }
     if (!$this->pretending) {
         try {
             return $this->swift->send($message, $this->failedRecipients);
         } finally {
             $this->swift->getTransport()->stop();
         }
     } elseif (isset($this->logger)) {
         $this->logMessage($message);
     }
 }
開發者ID:drickferreira,項目名稱:rastreador,代碼行數:21,代碼來源:Mailer.php

示例15: __construct

 /**
  * @param MauticFactory $factory
  * @param               $mailer
  * @param null          $from
  */
 public function __construct(MauticFactory $factory, \Swift_Mailer $mailer, $from = null)
 {
     $this->factory = $factory;
     $this->mailer = $mailer;
     $this->transport = $mailer->getTransport();
     try {
         $this->logger = new \Swift_Plugins_Loggers_ArrayLogger();
         $this->mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($this->logger));
     } catch (\Exception $e) {
         $this->logError($e);
     }
     $this->from = !empty($from) ? $from : array($factory->getParameter('mailer_from_email') => $factory->getParameter('mailer_from_name'));
     $this->returnPath = $factory->getParameter('mailer_return_path');
     // Check if batching is supported by the transport
     if ($this->factory->getParameter('mailer_spool_type') == 'memory' && $this->transport instanceof InterfaceTokenTransport) {
         $this->tokenizationSupported = true;
     }
     // Set factory if supported
     if (method_exists($this->transport, 'setMauticFactory')) {
         $this->transport->setMauticFactory($factory);
     }
     $this->message = $this->getMessageInstance();
 }
開發者ID:emtudo,項目名稱:mautic,代碼行數:28,代碼來源:MailHelper.php


注:本文中的Swift_Mailer::getTransport方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。