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


PHP Swift_Mailer::createMessage方法代码示例

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


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

示例1: composeMessage

 /**
  * @param EmailInterface $email
  *
  * @return \Swift_Message
  */
 private function composeMessage(EmailInterface $email)
 {
     /** @var $message \Swift_Message */
     $message = $this->mailer->createMessage();
     $message->setTo($email->getReceiver())->setSubject($email->getSubject())->setBody($email->getBody(), 'text/html');
     return $message;
 }
开发者ID:morganus,项目名称:Benchmarker,代码行数:12,代码来源:EmailService.php

示例2: execute

 /**
  * Execute Command
  *
  * @param InputInterface  $input
  * @param OutputInterface $output
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $email = $this->twig->render('test.twig');
     $message = $this->mailer->createMessage()->setSubject('PHP RFC Digestor Test Email')->setFrom('notifier@php-rfc-digestor.com')->setTo($input->getArgument('email'))->setBody($email, 'text/html');
     $this->mailer->send($message);
     $output->writeln(sprintf('<info>Email sent to %s</info>', $input->getArgument('email')));
 }
开发者ID:shakyShane,项目名称:php-rfc-digestor,代码行数:13,代码来源:Email.php

示例3: sendMail

 /**
  * @param UserInterface $user
  * @param string $subject
  * @param string $body
  */
 private function sendMail(UserInterface $user, $subject, $body)
 {
     $message = $this->mailer->createMessage();
     $to = array($user->getEmail() => $user->getUsername());
     $message = $message->setSubject($subject)->addFrom($this->mailSender, $this->mailSenderName)->setTo($to)->setBody($body, 'text/html');
     $this->mailer->send($message);
 }
开发者ID:ulakjira,项目名称:ojs,代码行数:12,代码来源:UserEventListener.php

示例4: process

 /**
  * Process email model sending.
  *
  * @param EmailModel $model
  * @return Email
  * @throws \Swift_SwiftException
  */
 public function process(EmailModel $model)
 {
     $this->assertModel($model);
     $messageDate = new \DateTime('now', new \DateTimeZone('UTC'));
     /** @var \Swift_Message $message */
     $message = $this->mailer->createMessage();
     $message->setDate($messageDate->getTimestamp());
     $message->setFrom($this->getAddresses($model->getFrom()));
     $message->setTo($this->getAddresses($model->getTo()));
     $message->setSubject($model->getSubject());
     $message->setBody($model->getBody(), $model->getType() === 'html' ? 'text/html' : 'text/plain');
     $messageId = $message->generateId();
     if (!$this->mailer->send($message)) {
         throw new \Swift_SwiftException('An email was not delivered.');
     }
     $origin = $this->getEmailOrigin($model->getFrom());
     $this->emailEntityBuilder->setOrigin($origin);
     $email = $this->emailEntityBuilder->email($model->getSubject(), $model->getFrom(), $model->getTo(), $messageDate, $messageDate, $messageDate);
     $email->addFolder($origin->getFolder(FolderType::SENT));
     $email->setEmailBody($this->emailEntityBuilder->body($model->getBody(), $model->getType() === 'html', true));
     $email->setMessageId($messageId);
     // persist the email and all related entities such as folders, email addresses etc.
     $this->emailEntityBuilder->getBatch()->persist($this->getEntityManager());
     // associate the email with the target entity if exist
     if ($model->hasEntity()) {
         $targetEntity = $this->doctrineHelper->getEntity($model->getEntityClass(), $model->getEntityId());
         if ($targetEntity) {
             $this->emailActivityManager->addAssociation($email, $targetEntity);
         }
     }
     // flush all changes to the database
     $this->getEntityManager()->flush();
     return $email;
 }
开发者ID:xamin123,项目名称:platform,代码行数:41,代码来源:Processor.php

示例5: notify

 /**
  * {@inheritdoc}
  */
 public function notify(array $users, $subject, $txtBody, $htmlBody = null, array $options = [])
 {
     foreach ($users as $user) {
         $message = $this->mailer->createMessage();
         $message->setSubject($subject)->setFrom($this->senderEmail)->setTo($user->getEmail())->setCharset('UTF-8')->setContentType('text/html')->setBody($txtBody, 'text/plain')->addPart($htmlBody, 'text/html');
         $this->mailer->send($message);
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:11,代码来源:MailNotifier.php

示例6: notify

 /**
  * @param Rfc $rfc
  * @param array $voteDiff
  */
 public function notify(Rfc $rfc, array $voteDiff)
 {
     foreach ($this->emailSubscriberRepository->findAll() as $subscriber) {
         $email = $this->twig->render('rfc.twig', ['rfcName' => $rfc->getName(), 'details' => $voteDiff['details'], 'changeLog' => $voteDiff['changeLog'], 'voteDiffs' => $voteDiff['votes'], 'rfcVotes' => $rfc->getVotes(), 'unsubscribeUrl' => sprintf('%s/unsubscribe/%s', $this->config->get('app.url'), $subscriber->getUnsubscribeToken())]);
         $message = $this->mailer->createMessage()->setSubject(sprintf('%s updated!', $rfc->getName()))->setFrom('notifier@php-rfc-digestor.com')->setTo($subscriber->getEmail())->setBody($email, 'text/html');
         $this->mailer->send($message);
     }
 }
开发者ID:shakyShane,项目名称:php-rfc-digestor,代码行数:12,代码来源:EmailRfcNotifier.php

示例7: sendAttributeSupportMail

 public function sendAttributeSupportMail()
 {
     $user = $this->userService->getUser();
     $body = $this->templateEngine->render('OpenConextProfileBundle:AttributeSupport:email.html.twig', ['attributes' => $user->getAttributes()]);
     /** @var Message $message */
     $message = $this->mailer->createMessage();
     $message->setFrom($this->mailFrom->getEmailAddress())->setTo($this->mailTo->getEmailAddress())->setSubject(sprintf('Personal debug info of %s', $user->getId()))->setBody($body, 'text/html', 'utf-8');
     $this->mailer->send($message);
 }
开发者ID:OpenConext,项目名称:OpenConext-profile,代码行数:9,代码来源:AttributeSupportMailService.php

示例8: createMessage

 /**
  * @param $subject
  * @param $template
  * @param $data
  * @param Request $request
  * @return mixed
  * @throws \Doctrine\ORM\ORMException
  * @throws \Doctrine\ORM\OptimisticLockException
  * @throws \Doctrine\ORM\TransactionRequiredException
  * @throws \Exception
  * @throws \Twig_Error
  *
  * @return \Swift_Message
  */
 public function createMessage($subject, $template, $data, Request $request = null)
 {
     $history = null;
     if ($request && $request->cookies->has('tracker_id')) {
         /** @var \keltanas\Bundle\TrackingBundle\Entity\History $history */
         $history = $this->em->find('keltanasTrackingBundle:History', $request->cookies->get('tracker_id'));
     }
     $message = $this->mailer->createMessage()->setSubject($subject)->setFrom($this->from)->setTo($this->to)->setBody($this->templating->render($template, ['data' => $data, 'history' => $history]), 'text/html', 'utf-8');
     return $message;
 }
开发者ID:keltanas,项目名称:landing-tracking-bundle,代码行数:24,代码来源:Postman.php

示例9: sendEmail

 /**
  * @param \Sonata\NotificationBundle\Model\MessageInterface $message
  */
 private function sendEmail(MessageInterface $message)
 {
     $mail = $this->mailer->createMessage()->setSubject($message->getValue('subject'))->setFrom(array($message->getValue(array('from', 'email')) => $message->getValue(array('from', 'name'))))->setTo($message->getValue('to'));
     if ($text = $message->getValue(array('message', 'text'))) {
         $mail->addPart($text, 'text/plain');
     }
     if ($html = $message->getValue(array('message', 'html'))) {
         $mail->addPart($html, 'text/html');
     }
     $this->mailer->send($mail);
 }
开发者ID:rubenrua,项目名称:SonataNotificationBundle,代码行数:14,代码来源:SwiftMailerConsumer.php

示例10: sendResetEmail

 /**
  * Sends reset email
  * @param string $email
  * @param string $activationHash
  * @return void
  */
 public function sendResetEmail($email, $activationHash)
 {
     /** @var \Swift_Message $confirmation */
     $confirmation = $this->mailer->createMessage();
     $confirmation->setSubject('Reset your password');
     $confirmation->setFrom($this->senderEmail);
     $confirmation->setTo($email);
     $confirmation->setReplyTo($this->senderEmail);
     $confirmation->setBody($this->twig->render($this->txtTwigTemplate, array('activation_hash' => $activationHash)), 'text/plain');
     $confirmation->addPart($this->twig->render($this->htmlTwigTemplate, array('activation_hash' => $activationHash)), 'text/html');
     $this->mailer->send($confirmation);
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:18,代码来源:ResetPasswordMailer.php

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

示例12: message

 /**
  * @param Notification $notification
  *
  * @return \Swift_Message
  */
 private function message(Notification $notification)
 {
     /** @var \Swift_Message $message */
     $message = $this->mailer->createMessage();
     $message->setSubject(ucfirst($notification->getHeaderText()));
     $senderName = $this->configManager->get('oro_notification.email_notification_sender_name');
     $message->setFrom($this->senderEmail, $senderName);
     $mail = $notification->getAuthor()->getEmail();
     $message->setTo($mail);
     $options = array('user' => $this->getFormattedUserName($notification), 'header' => $notification->getHeaderText());
     $txtTemplate = $this->templateResolver->resolve($notification, TemplateResolver::TYPE_TXT);
     $htmlTemplate = $this->templateResolver->resolve($notification, TemplateResolver::TYPE_HTML);
     $message->setBody($this->twig->render($txtTemplate, $options), 'text/plain');
     $message->addPart($this->twig->render($htmlTemplate, $options), 'text/html');
     return $message;
 }
开发者ID:gitter-badger,项目名称:diamantedesk-application,代码行数:21,代码来源:EmailNotifier.php

示例13: assignResetCredentialCode

 public function assignResetCredentialCode($emailAddress)
 {
     $emailAddressRepository = $this->entityManager->getRepository(EmailEntity::class);
     /** @var EmailEntity $emailAddress */
     $emailAddress = $emailAddressRepository->findOneBy(['address' => $emailAddress]);
     if (!$emailAddress || !$emailAddress->isVerified()) {
         return;
     }
     mail('walter.tamboer@live.com', 'Subject', 'data');
     exit('done');
     $validChars = implode('', array_merge(range('a', 'z'), range('A', 'Z'), range('0', '9')));
     $emailAddress->getAccount()->setResetCredentialCode(Rand::getString(32, $validChars));
     $this->passwordChanger->flush($emailAddress->getAccount());
     $transport = \Swift_MailTransport::newInstance();
     $logger = new \Swift_Plugins_Loggers_EchoLogger();
     $mailer = new \Swift_Mailer($transport);
     $mailer->registerPlugin(new \Swift_Plugins_LoggerPlugin($logger));
     /** @var \Swift_Message $message */
     $message = $mailer->createMessage();
     $message->setTo($emailAddress->getAddress());
     //$message->setBoundary('zource_' . md5(time()));
     $message->setSubject('Test');
     $message->setBody('This is a test.');
     $message->addPart('<q>Here is the message itself</q>', 'text/html');
     $failures = [];
     $result = $mailer->send($message, $failures);
     var_dump($data, $failures, $result, $logger->dump());
     exit;
 }
开发者ID:zource,项目名称:zource,代码行数:29,代码来源:PasswordChanger.php

示例14: notify

 /**
  * {@inheritdoc}
  */
 public function notify(JobExecution $jobExecution)
 {
     if (null === ($email = $this->getEmail())) {
         return;
     }
     $parameters = array('jobExecution' => $jobExecution, 'log' => $this->logger->getFilename());
     $txtBody = $this->twig->render('AkeneoBatchBundle:Mails:notification.txt.twig', $parameters);
     $htmlBody = $this->twig->render('AkeneoBatchBundle:Mails:notification.html.twig', $parameters);
     $message = $this->mailer->createMessage();
     $message->setSubject('Job has been executed');
     $message->setFrom($this->senderEmail);
     $message->setTo($email);
     $message->setBody($txtBody, 'text/plain');
     $message->addPart($htmlBody, 'text/html');
     $this->mailer->send($message);
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:19,代码来源:MailNotifier.php

示例15: sendPassword

 /**
  * @param User $user
  * @param $plainPassword
  *
  * @return array|bool
  */
 public function sendPassword(User $user, $plainPassword)
 {
     /* @var \Swift_Message $message */
     $message = $this->mailer->createMessage();
     $locale = $this->getLocale($user);
     $subject = T::trans('Your password', array(), 'mail', $locale);
     $body = T::trans('Your new password is: %plainPassword%', array('%plainPassword%' => $plainPassword), 'mail', $locale);
     $message->setFrom($this->mailSender);
     $message->setTo($user->getEmail());
     $message->setSubject($subject);
     $message->setBody($body);
     $failedRecipients = array();
     if (!$this->mailer->send($message, $failedRecipients)) {
         return $failedRecipients;
     }
     return true;
 }
开发者ID:sttas,项目名称:ModeraBackendSecurityBundle,代码行数:23,代码来源:MailService.php


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