当前位置: 首页>>代码示例>>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;未经允许,请勿转载。