• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Swift_Image类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: embed

 protected function embed($path)
 {
     if (!$path instanceof Swift_Image) {
         $path = Swift_Image::fromPath($path);
     }
     return $this->message->embed($path);
 }
开发者ID:alshabalin,项目名称:kohana-advanced-mailer,代码行数:7,代码来源:Mailer.php


示例2: sendMessage

 /**
  * @param string $templateName
  * @param array  $context
  * @param string $fromEmail
  * @param string $toEmail
  */
 protected function sendMessage($templateName, $context, $fromEmail, $toEmail)
 {
     //new instance
     $message = \Swift_Message::newInstance();
     $context = $this->twig->mergeGlobals($context);
     //merge context
     $template = $this->twig->loadTemplate($templateName);
     //espacio para agregar imágenes
     $context['image_src'] = $message->embed(\Swift_Image::fromPath('images/email_header.png'));
     //attach image 1
     $context['fb_image'] = $message->embed(\Swift_Image::fromPath('images/fb.gif'));
     //attach image 2
     $context['tw_image'] = $message->embed(\Swift_Image::fromPath('images/tw.gif'));
     //attach image 3
     $context['right_image'] = $message->embed(\Swift_Image::fromPath('images/right.gif'));
     //attach image 4
     $context['left_image'] = $message->embed(\Swift_Image::fromPath('images/left.gif'));
     //attach image 5
     $subject = $template->renderBlock('subject', $context);
     $textBody = $template->renderBlock('body_text', $context);
     $htmlBody = $template->renderBlock('body_html', $context);
     $message->setSubject($subject)->setFrom($fromEmail)->setTo($toEmail);
     if (!empty($htmlBody)) {
         $message->setBody($htmlBody, 'text/html')->addPart($textBody, 'text/plain');
     } else {
         $message->setBody($textBody);
     }
     $this->mailer->send($message);
 }
开发者ID:Newton-Labs,项目名称:HospitalRecord,代码行数:35,代码来源:CustomTwigSwiftMailer.php


示例3: insertImages

 /**
  * Inserts images without using getTemplate.
  *
  * @param string $message
  * @param string $content
  *
  * @return mixed
  */
 public function insertImages($message, $content)
 {
     foreach ($this->images as $name => $image_path) {
         $image_embed = $message->embed(\Swift_Image::fromPath($image_path));
         $content = str_replace(rawurlencode('{{ ' . $name . ' }}'), $image_embed, $content);
     }
     return $content;
 }
开发者ID:TheCodemasterZz,项目名称:PhalconUserPlugin,代码行数:16,代码来源:Mail.php


示例4: postAction

 /**
  *
  * @return RedirectResponse|Response
  */
 public function postAction()
 {
     $urlFrom = $this->getReferer();
     if (null == $urlFrom || trim($urlFrom) == '') {
         $urlFrom = $this->generateUrl('_front_devis');
     }
     $devisNewForm = $this->createForm(DevisNewTForm::class);
     $request = $this->getRequest();
     $reqData = $request->request->all();
     if (isset($reqData['DevisNewForm'])) {
         $devisNewForm->handleRequest($request);
         if ($devisNewForm->isValid()) {
             $from = $this->getParameter('mail_from');
             $fromName = $this->getParameter('mail_from_name');
             $subject = $this->translate('_mail.devis.subject', array(), 'messages');
             $mvars = array();
             $mvars['firstname'] = $devisNewForm['firstname']->getData();
             $mvars['lastname'] = $devisNewForm['lastname']->getData();
             $mvars['email'] = $devisNewForm['email']->getData();
             $mvars['phone'] = $devisNewForm['phone']->getData();
             $mvars['entreprise'] = $devisNewForm['entreprise']->getData();
             $mvars['entrepriseForm'] = $devisNewForm['entrepriseForm']->getData();
             $mvars['activity'] = $devisNewForm['activity']->getData();
             $mvars['dtActivation'] = $devisNewForm['dtActivation']->getData();
             $mvars['address'] = $devisNewForm['address']->getData();
             $mvars['zipCode'] = $devisNewForm['zipCode']->getData();
             $mvars['town'] = $devisNewForm['town']->getData();
             $mvars['caYear'] = $devisNewForm['caYear']->getData();
             $mvars['nbrInvoicesBuy'] = $devisNewForm['nbrInvoicesBuy']->getData();
             $mvars['nbrInvoicesSale'] = $devisNewForm['nbrInvoicesSale']->getData();
             $mvars['nbrSalaries'] = $devisNewForm['nbrSalaries']->getData();
             $mvars['hasexpert'] = $devisNewForm['hasexpert']->getData();
             $mvars['otherInfos'] = $devisNewForm['otherInfos']->getData();
             try {
                 $admins = $this->getParameter('mailtos');
                 $message = \Swift_Message::newInstance()->setFrom($from, $fromName);
                 foreach ($admins as $admin) {
                     $message->addTo($admin['email'], $admin['name']);
                     $message->setReplyTo($mvars['email'], $mvars['lastname'] . ' ' . $mvars['firstname']);
                 }
                 $message->setSubject($subject);
                 $mvars['logo'] = $message->embed(\Swift_Image::fromPath($this->getParameter('kernel.root_dir') . '/../web/bundles/acfres/images/logo_acf.jpg'));
                 $message->setBody($this->renderView('AcfFrontBundle:Mail:devis.html.twig', $mvars), 'text/html');
                 $this->sendmail($message);
             } catch (\Exception $e) {
                 $logger = $this->getLogger();
                 $logger->addError($e->getMessage());
             }
             $this->flashMsgSession('success', $this->translate('_front.devis.success'));
             return $this->redirect($this->generateUrl('_front_devis'));
         } else {
             $this->gvars['DevisNewForm'] = $devisNewForm->createView();
             $this->flashMsgSession('error', $this->translate('_front.devis.error'));
             return $this->renderResponse('AcfFrontBundle:Default:devis.html.twig', $this->gvars);
         }
     }
     return $this->redirect($urlFrom);
 }
开发者ID:sasedev,项目名称:acf-expert,代码行数:62,代码来源:DevisController.php


示例5: _embedContentImages

 /**
  * @param \Swift_Message $messageInstance
  * @param $contentHtml
  * @param array $embeddedImages
  *
  * @return mixed
  */
 protected function _embedContentImages(\Swift_Message $messageInstance, $contentHtml, array $embeddedImages)
 {
     if ($embeddedImages !== NULL) {
         foreach ($embeddedImages as $stackIndex => $pathImage) {
             $cid = $messageInstance->embed(\Swift_Image::fromPath($pathImage));
             $contentHtml = str_replace('{{imageStackIndex:' . $stackIndex . '}}', $cid, $contentHtml);
         }
     }
     return $contentHtml;
 }
开发者ID:gamespree,项目名称:simplon_email,代码行数:17,代码来源:Email.php


示例6: embedImage

 /**
  * Embed the image in message and replace the image link by attachment id.
  *
  * @param \Swift_Message $message The swift mailer message
  * @param \DOMAttr       $node    The dom attribute of image
  * @param array          $images  The map of image ids passed by reference
  */
 protected function embedImage(\Swift_Message $message, \DOMAttr $node, array &$images)
 {
     if (0 === strpos($node->nodeValue, 'cid:')) {
         return;
     }
     if (isset($images[$node->nodeValue])) {
         $node->nodeValue = $images[$node->nodeValue];
     } else {
         $node->nodeValue = EmbedImageUtil::getLocalPath($node->nodeValue, $this->webDir, $this->hostPattern);
         $cid = $message->embed(\Swift_Image::fromPath($node->nodeValue));
         $images[$node->nodeValue] = $cid;
         $node->nodeValue = $cid;
     }
 }
开发者ID:sonatra,项目名称:SonatraMailerBundle,代码行数:21,代码来源:EmbedImagePlugin.php


示例7: sendMail

 public static function sendMail($name, $email, $template)
 {
     $message = Swift_Message::newInstance()->setSubject($template->getSubject())->setFrom(array('[email protected]' => 'Dahlen'))->setTo(array($email => $name));
     $imageMatches = array();
     $html = $template->getHTML();
     if (preg_match_all('/<img.*?src="(.*?)".*?\\/>/', $html, $imageMatches, PREG_PATTERN_ORDER) > 0) {
         foreach ($imageMatches[0] as $index => $fullMatch) {
             $html = str_replace($imageMatches[1][$index], $message->embed(Swift_Image::fromPath(str_replace('http://' . $_SERVER['SERVER_NAME'], ROOT_DIR, $imageMatches[1][$index]), $html)), $html);
         }
     }
     $message->setBody($html, 'text/html')->addPart($template->getPlainText(), 'text/plain');
     $transport = Swift_SmtpTransport::newInstance(self::$SMTP_SERVER, 25)->setUsername(self::$USERNAME)->setPassword(self::$PASSWORD);
     $mailer = Swift_Mailer::newInstance($transport);
     return $mailer->send($message);
 }
开发者ID:elpadi,项目名称:dahlen-studio,代码行数:15,代码来源:mailer.php


示例8: envoyerMailTousLesAbonnes

 public function envoyerMailTousLesAbonnes(Notification $notif)
 {
     //On récupère tous les abonnés en base de donnée
     $abonnes = $this->repo->findAll();
     //On construit le mail à envoyer (objet, corps du message, inclusion d'images)
     $objet = str_replace("{SUJET}", $notif->getSujet(), $this->mailSubject);
     $message = \Swift_Message::newInstance($objet);
     $urlLogoSopra = "http://localhost" . $this->container->get('templating.helper.assets')->getUrl('images/logo.png');
     $urlLogoSopra = $message->embed(\Swift_Image::fromPath($urlLogoSopra));
     $message->setFrom($this->mailSender)->setBody($this->templating->render('AbonnementBundle:Abonne:mail.html.twig', array("lien" => $notif->getLien(), "resume" => $notif->getResume(), "urlImage" => $urlLogoSopra)), 'text/html');
     //On envoie un mail à chaque abonné :
     foreach ($abonnes as $abonne) {
         $message->setTo($abonne->getMail());
         $this->mailer->send($message);
     }
 }
开发者ID:remi-picard,项目名称:techlunch-symfony2,代码行数:16,代码来源:NotificationManager.php


示例9: testEmbeddedFilesWithMultipartDataCreateMultipartRelatedContentAsAnAlternative

 public function testEmbeddedFilesWithMultipartDataCreateMultipartRelatedContentAsAnAlternative()
 {
     $message = Swift_Message::newInstance();
     $message->setCharset('utf-8');
     $message->setSubject('test subject');
     $message->addPart('plain part', 'text/plain');
     $image = Swift_Image::newInstance('<image data>', 'image.gif', 'image/gif');
     $cid = $message->embed($image);
     $message->setBody('<img src="' . $cid . '" />', 'text/html');
     $message->setTo(array('[email protected]' => 'User'));
     $message->setFrom(array('[email protected]' => 'Other'));
     $message->setSender(array('[email protected]' => 'Other'));
     $id = $message->getId();
     $date = preg_quote(date('r', $message->getDate()), '~');
     $boundary = $message->getBoundary();
     $cidVal = $image->getId();
     $this->assertRegExp('~^' . 'Sender: Other <[email protected]>' . "\r\n" . 'Message-ID: <' . $id . '>' . "\r\n" . 'Date: ' . $date . "\r\n" . 'Subject: test subject' . "\r\n" . 'From: Other <[email protected]>' . "\r\n" . 'To: User <[email protected]>' . "\r\n" . 'MIME-Version: 1.0' . "\r\n" . 'Content-Type: multipart/alternative;' . "\r\n" . ' boundary="' . $boundary . '"' . "\r\n" . "\r\n\r\n" . '--' . $boundary . "\r\n" . 'Content-Type: text/plain; charset=utf-8' . "\r\n" . 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . "\r\n" . 'plain part' . "\r\n\r\n" . '--' . $boundary . "\r\n" . 'Content-Type: multipart/related;' . "\r\n" . ' boundary="(.*?)"' . "\r\n" . "\r\n\r\n" . '--\\1' . "\r\n" . 'Content-Type: text/html; charset=utf-8' . "\r\n" . 'Content-Transfer-Encoding: quoted-printable' . "\r\n" . "\r\n" . '<img.*?/>' . "\r\n\r\n" . '--\\1' . "\r\n" . 'Content-Type: image/gif; name=image.gif' . "\r\n" . 'Content-Transfer-Encoding: base64' . "\r\n" . 'Content-Disposition: inline; filename=image.gif' . "\r\n" . 'Content-ID: <' . $cidVal . '>' . "\r\n" . "\r\n" . preg_quote(base64_encode('<image data>'), '~') . "\r\n\r\n" . '--\\1--' . "\r\n" . "\r\n\r\n" . '--' . $boundary . '--' . "\r\n" . '$~D', $message->toString());
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:18,代码来源:Bug34Test.php


示例10: rechazarAction

 public function rechazarAction($id)
 {
     //Enviar correo al estudiante
     $em = $this->getDoctrine()->getManager();
     $solicitud = $em->getRepository('EstudianteBundle:Solicitud')->find($id);
     $estudiante = $solicitud->getEstudiante();
     /*         * ********************Mail ****************************** */
     $message = \Swift_Message::newInstance('Solicitud Rechazada');
     $message->setFrom('[email protected]');
     $message->setTo($estudiante->getCorreo());
     $message->setBody('<html>' . ' <head> <img src="' . $message->embed(\Swift_Image::fromPath('images/logoHeader.png')) . '" /></head>' . ' <body>' . ' <br><br><br><span style="font-size:18px">Estimado estudiante, su solicitud a la sección ' . $solicitud->getSeccion()->getMateria()->getNombre() . '-' . $solicitud->getSeccion()->getCodigo() . ' ha sido rechazada por el profesor. </span> ' . ' </body>' . '<br><br><br><footer>EvaluaUcab Todos los derechos reservados</footer>' . '</html>', 'text/html');
     $this->get('mailer')->send($message);
     $solicitud->setStatus('Rechazada');
     /*         * ****************************************************** */
     $em->remove($solicitud);
     $em->flush();
     $this->getRequest()->getSession()->getFlashBag()->add('warning', '¡Solicitud Rechazada!');
     return $this->render('ProfesorBundle:Default:solicitudes.html.twig');
 }
开发者ID:lvfb20,项目名称:evaluaUcab,代码行数:19,代码来源:SolicitudController.php


示例11: embedImages

 /**
  * @param Swift_Mime_Message $message
  * @param Swift_Mime_MimeEntity $part
  *
  * @return string
  */
 protected function embedImages(Swift_Mime_Message $message, Swift_Mime_MimeEntity $part = null)
 {
     $body = $part === null ? $message->getBody() : $part->getBody();
     $dom = new \DOMDocument('1.0');
     $dom->loadHTML($body);
     $images = $dom->getElementsByTagName('img');
     foreach ($images as $image) {
         $src = $image->getAttribute('src');
         /**
          * Prevent beforeSendPerformed called twice
          * see https://github.com/swiftmailer/swiftmailer/issues/139
          */
         if (strpos($src, 'cid:') === false) {
             $entity = \Swift_Image::fromPath($src);
             $message->setChildren(array_merge($message->getChildren(), [$entity]));
             $image->setAttribute('src', 'cid:' . $entity->getId());
         }
     }
     return $dom->saveHTML();
 }
开发者ID:hexanet,项目名称:swiftmailer-image-embed,代码行数:26,代码来源:ImageEmbedPlugin.php


示例12: sendTemplateMail

 public function sendTemplateMail(SendTemplateMailCommand $command)
 {
     $message = \Swift_Message::newInstance();
     $ext = $command->format === 'text/html' ? 'html' : 'txt';
     $tplIdentifier = 'Email/' . $command->template . '.' . $ext;
     $template = $this->cr->getContent($tplIdentifier);
     $templateData = $command->templateData;
     if ($command->image !== null) {
         $templateData['image'] = $message->embed(\Swift_Image::fromPath($command->image));
     }
     // Subject
     $env = new \Twig_Environment(new \Twig_Loader_String());
     $subject = $template->getProperties()->containsKey('subject') ? $template->getProperties()->get('subject') : $this->mailFromName;
     $subject = $env->render($subject, $templateData);
     // Body
     $body = $this->templating->render('bcrm_content:' . $tplIdentifier, $templateData);
     $message->setCharset('UTF-8');
     $message->setFrom($this->mailFromEmail, $this->mailFromName)->setSubject($subject)->setTo($command->email)->setBody($body, $command->format);
     $this->mailer->send($message);
 }
开发者ID:Ravetracer,项目名称:www,代码行数:20,代码来源:Mail.php


示例13: testEmbeddedImagesAreEmbedded

 public function testEmbeddedImagesAreEmbedded()
 {
     $message = Swift_Message::newInstance()->setFrom('[email protected]')->setTo('[email protected]')->setSubject('test');
     $cid = $message->embed(Swift_Image::fromPath(__DIR__ . '/../../_samples/files/swiftmailer.png'));
     $message->setBody('<img src="' . $cid . '" />', 'text/html');
     $that = $this;
     $messageValidation = function (Swift_Mime_Message $message) use($that) {
         preg_match('/cid:(.*)"/', $message->toString(), $matches);
         $cid = $matches[1];
         preg_match('/Content-ID: <(.*)>/', $message->toString(), $matches);
         $contentId = $matches[1];
         $that->assertEquals($cid, $contentId, 'cid in body and mime part Content-ID differ');
         return true;
     };
     $failedRecipients = array();
     $transport = m::mock('Swift_Transport');
     $transport->shouldReceive('isStarted')->andReturn(true);
     $transport->shouldReceive('send')->with(m::on($messageValidation), $failedRecipients)->andReturn(1);
     $memorySpool = new Swift_MemorySpool();
     $memorySpool->queueMessage($message);
     $memorySpool->flushQueue($transport, $failedRecipients);
 }
开发者ID:Ceciceciceci,项目名称:MySJSU-Class-Registration,代码行数:22,代码来源:Bug534Test.php


示例14: transform

 /**
  * {@inheritdoc)
  */
 public function transform(\Swift_Mime_Message $message)
 {
     $body = $message->getBody();
     $body = preg_replace_callback('/(src|background)="(http[^"]*)"/', function ($matches) use($message) {
         $attribute = $matches[1];
         $imagePath = $matches[2];
         if ($fp = fopen($imagePath, "r")) {
             $imagePath = $message->embed(\Swift_Image::fromPath($imagePath));
             fclose($fp);
         }
         return sprintf('%s="%s"', $attribute, $imagePath);
     }, $body);
     $body = preg_replace_callback('/url\\((http[^"]*)\\)/', function ($matches) use($message) {
         $imagePath = $matches[1];
         if ($fp = fopen($imagePath, "r")) {
             $imagePath = $message->embed(\Swift_Image::fromPath($imagePath));
             fclose($fp);
         }
         return sprintf('url(%s)', $imagePath);
     }, $body);
     $message->setBody($body, 'text/html');
 }
开发者ID:rezzza,项目名称:MailExtraBundle,代码行数:25,代码来源:PictureEmbedTransformer.php


示例15: sendMail

 function sendMail($smtp_server, $to, $from, $subject, $body, $cc, $bcc, $attachments = null, $smtp_port = 25, $smtp_username = null, $smtp_password = '', $type = 'text/plain', $transport = 0, $message_id = null, $in_reply_to = null, $inline_images = null, &$complete_mail, $att_version)
 {
     //Load in the files we'll need
     Env::useLibrary('swift');
     try {
         $mail_transport = Swift_SmtpTransport::newInstance($smtp_server, $smtp_port, $transport);
         $smtp_authenticate = $smtp_username != null;
         if ($smtp_authenticate) {
             $mail_transport->setUsername($smtp_username);
             $mail_transport->setPassword(self::ENCRYPT_DECRYPT($smtp_password));
         }
         $mailer = Swift_Mailer::newInstance($mail_transport);
         // init Swift logger
         if (defined('LOG_SWIFT') && LOG_SWIFT > 0) {
             $swift_logger = new Swift_Plugins_Loggers_ArrayLogger();
             $mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($swift_logger));
             $swift_logger_level = LOG_SWIFT;
             // 0: no log, 1: log only errors, 2: log everything
         } else {
             $swift_logger_level = 0;
         }
         if (is_string($from)) {
             $pos = strrpos($from, "<");
             if ($pos !== false) {
                 $sender_name = trim(substr($from, 0, $pos));
                 $sender_address = str_replace(array("<", ">"), array("", ""), trim(substr($from, $pos, strlen($from) - 1)));
             } else {
                 $sender_name = "";
                 $sender_address = $from;
             }
             $from = array($sender_address => $sender_name);
         }
         //Create a message
         $message = Swift_Message::newInstance($subject)->setFrom($from)->setContentType($type);
         $to = self::prepareEmailAddresses($to);
         $cc = self::prepareEmailAddresses($cc);
         $bcc = self::prepareEmailAddresses($bcc);
         foreach ($to as $address) {
             $message->addTo(array_var($address, 0), array_var($address, 1, ""));
         }
         foreach ($cc as $address) {
             $message->addCc(array_var($address, 0), array_var($address, 1, ""));
         }
         foreach ($bcc as $address) {
             $message->addBcc(array_var($address, 0), array_var($address, 1, ""));
         }
         if ($in_reply_to) {
             if (str_starts_with($in_reply_to, "<")) {
                 $in_reply_to = substr($in_reply_to, 1, -1);
             }
             $validator = new SwiftHeaderValidator();
             if ($validator->validate_id_header_value($in_reply_to)) {
                 $message->getHeaders()->addIdHeader("In-Reply-To", $in_reply_to);
             }
         }
         if ($message_id) {
             if (str_starts_with($message_id, "<")) {
                 $message_id = substr($message_id, 1, -1);
             }
             $message->setId($message_id);
         }
         // add attachments
         if (is_array($attachments)) {
             foreach ($attachments as $att) {
                 if ($att_version < 2) {
                     $swift_att = Swift_Attachment::newInstance($att["data"], $att["name"], $att["type"]);
                 } else {
                     $swift_att = Swift_Attachment::fromPath($att['path'], $att['type']);
                     $swift_att->setFilename($att["name"]);
                 }
                 if (substr($att['name'], -4) == '.eml') {
                     $swift_att->setEncoder(Swift_Encoding::get7BitEncoding());
                     $swift_att->setContentType('message/rfc822');
                 }
                 $message->attach($swift_att);
             }
         }
         // add inline images
         if (is_array($inline_images)) {
             foreach ($inline_images as $image_url => $image_path) {
                 $cid = $message->embed(Swift_Image::fromPath($image_path));
                 $body = str_replace($image_url, $cid, $body);
             }
         }
         self::adjustBody($message, $type, $body);
         $message->setBody($body);
         //Send the message
         $complete_mail = self::retrieve_original_mail_code($message);
         $result = $mailer->send($message);
         if ($swift_logger_level >= 2 || $swift_logger_level > 0 && !$result) {
             file_put_contents(CACHE_DIR . "/swift_log.txt", "\n" . gmdate("Y-m-d H:i:s") . " DEBUG:\n" . $swift_logger->dump() . "----------------------------------------------------------------------------", FILE_APPEND);
             $swift_logger->clear();
         }
         return $result;
     } catch (Exception $e) {
         Logger::log("ERROR SENDING EMAIL: " . $e->getTraceAsString(), Logger::ERROR);
         //if there is an error with the connection, let the user know about it
         $mail_error = $e->getMessage();
         $mail_error = stristr($mail_error, 'Log data:', true);
         flash_error(lang('mail not sent') . " '" . $mail_error . "'");
//.........这里部分代码省略.........
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:MailUtilities.class.php


示例16: attachImagesToMessageAndSetBody

function attachImagesToMessageAndSetBody(&$message, $body)
{
    $imagesInMessage = getImagesInMessage($body);
    foreach ($imagesInMessage as $imageUrl) {
        try {
            $cid = $message->embed(Swift_Image::fromPath($imageUrl));
            $body = str_replace($imageUrl, $cid, $body);
        } catch (Exception $exp) {
        }
    }
    $message->setBody($body, 'text/html');
}
开发者ID:rpiket,项目名称:WP-Autoresponder,代码行数:12,代码来源:mail_functions.php


示例17: catch

$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::NewInstance()->setSubject(__("Recent Data Center Installations Report"));
// Set from address
try {
    $message->setFrom($config->ParameterArray['MailFromAddr']);
} catch (Swift_RfcComplianceException $e) {
    $error .= __("MailFrom") . ": <span class=\"errmsg\">" . $e->getMessage() . "</span><br>\n";
}
// Add data center team to the list of recipients
try {
    $message->addTo($config->ParameterArray['FacMgrMail']);
} catch (Swift_RfcComplianceException $e) {
    $error .= __("Facility Manager email address") . ": <span class=\"errmsg\">" . $e->getMessage() . "</span><br>\n";
}
$logo = getcwd() . '/images/' . $config->ParameterArray["PDFLogoFile"];
$logo = $message->embed(Swift_Image::fromPath($logo)->setFilename('logo.png'));
$htmlMessage = sprintf("<!doctype html><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><meta http-equiv=\"CACHE-CONTROL\" content=\"NO-CACHE\"><meta http-equiv=\"expires\" content=\"Mon, 01 Jan 1997 01:00:00 GMT\"><meta http-equiv=\"PRAGMA\" content=\"NO-CACHE\"><title>ITS Data Center Inventory</title></head><body><div id=\"header\" style=\"padding: 5px 0;background: %s;\"><center><img src=\"%s\"></center></div><div class=\"page\"><p><h3>Installations in the Past 7 Days</h3>\n", $config->ParameterArray["HeaderColor"], $logo);
$htmlMessage .= sprintf("<p>The following systems have been entered into openDCIM, with an Install Date set to within the past %d days.  Please review these entries to determine if follow-up documentation is required.</p>", $config->ParameterArray["NewInstallsPeriod"]);
if (sizeof($devList) == 0) {
    $htmlMessage .= "<p>There are no recorded installations within the date range specified.</p>\n";
} else {
    $cab = new Cabinet();
    $dc = new DataCenter();
    $dept = new Department();
    $htmlMessage .= "<table>\n<tr><th>Installed Date</th><th>Reserved</th><th>Data Center</th><th>Location</th><th>Label</th><th>Owner</th></tr>\n";
    foreach ($devList as $devRow) {
        $cab->CabinetID = $devRow->Cabinet;
        $cab->GetCabinet();
        $dc->DataCenterID = $cab->DataCenterID;
        $dc->GetDataCenter();
        $dept->DeptID = $devRow->Owner;
开发者ID:paragm,项目名称:openDCIM,代码行数:31,代码来源:report-em_new_installs.php


示例18: embed

 /**
  * Embed an image
  *
  * @param   string  image path
  * @return  Embedded image
  */
 public function embed($image_path)
 {
     return $this->_message->embed(Swift_Image::fromPath($image_path));
 }
开发者ID:deraemons,项目名称:deraemon-cms,代码行数:10,代码来源:Email.php


示例19: editPostAction

 /**
  *
  * @param string $uid
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function editPostAction($uid)
 {
     $urlFrom = $this->getReferer();
     if (null == $urlFrom || trim($urlFrom) == '') {
         $urlFrom = $this->generateUrl('_admin_company_list');
     }
     $em = $this->getEntityManager();
     try {
         $customer = $em->getRepository('AcfDataBundle:Customer')->find($uid);
         if (null == $customer) {
             $this->flashMsgSession('warning', $this->translate('Customer.edit.notfound'));
         } else {
             $traces = $em->getRepository('AcfDataBundle:Trace')->getAllByEntityId($customer->getId(), Trace::AE_CUSTOMER);
             $this->gvars['traces'] = array_reverse($traces);
             $customerUpdateForm = $this->createForm(CustomerUpdateTForm::class, $customer);
             $customerUpdateDocsForm = $this->createForm(CustomerUpdateDocsTForm::class, $customer, array('company' => $customer->getCompany()));
             $doc = new Doc();
             $doc->setCompany($customer->getCompany());
             $docNewForm = $this->createForm(DocNewTForm::class, $doc, array('company' => $customer->getCompany()));
             $this->gvars['tabActive'] = $this->getSession()->get('tabActive', 2);
             $this->getSession()->remove('tabActive');
             $this->gvars['stabActive'] = $this->getSession()->get('stabActive', 1);
             $this->getSession()->remove('stabActive');
             $request = $this->getRequest();
             $reqData = $request->request->all();
             $cloneCustomer = clone $customer;
             if (isset($reqData['CustomerUpdateForm'])) {
                 $this->gvars['tabActive'] = 2;
                 $this->getSession()->set('tabActive', 2);
                 $customerUpdateForm->handleRequest($request);
                 if ($customerUpdateForm->isValid()) {
                     $em->persist($customer);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('Customer.edit.success', array('%customer%' => $customer->getLabel())));
                     $this->traceEntity($cloneCustomer, $customer);
                     return $this->redirect($urlFrom);
                 } else {
                     $em->refresh($customer);
                     $this->flashMsgSession('error', $this->translate('Customer.edit.failure', array('%customer%' => $customer->getLabel())));
                 }
             } elseif (isset($reqData['DocNewForm'])) {
                 $this->gvars['tabActive'] = 3;
                 $this->getSession()->set('tabActive', 3);
                 $this->gvars['stabActive'] = 1;
                 $this->getSession()->set('stabActive', 1);
                 $docNewForm->handleRequest($request);
                 if ($docNewForm->isValid()) {
                     $docs = array();
                     $docFiles = $docNewForm['fileName']->getData();
                     $docDir = $this->getParameter('kernel.root_dir') . '/../web/res/docs';
                     $docNames = '';
                     foreach ($docFiles as $docFile) {
                         $originalName = $docFile->getClientOriginalName();
                         $fileName = sha1(uniqid(mt_rand(), true)) . '.' . strtolower($docFile->getClientOriginalExtension());
                         $mimeType = $docFile->getMimeType();
                         $docFile->move($docDir, $fileName);
                         $size = filesize($docDir . '/' . $fileName);
                         $md5 = md5_file($docDir . '/' . $fileName);
                         $doc = new Doc();
                         $doc->setCompany($customer->getCompany());
                         $doc->setFileName($fileName);
                         $doc->setOriginalName($originalName);
                         $doc->setSize($size);
                         $doc->setMimeType($mimeType);
                         $doc->setMd5($md5);
                         $doc->setDescription($docNewForm['description']->getData());
                         $em->persist($doc);
                         $customer->addDoc($doc);
                         $docNames .= $doc->getOriginalName() . ' ';
                         $docs[] = $doc;
                     }
                     $em->persist($customer);
                     $em->flush();
                     $this->flashMsgSession('success', $this->translate('Doc.add.success', array('%doc%' => $docNames)));
                     $from = $this->getParameter('mail_from');
                     $fromName = $this->getParameter('mail_from_name');
                     $subject = $this->translate('_mail.newdocsCloud.subject', array(), 'messages');
                     $company = $customer->getCompany();
                     $acfCloudRole = $em->getRepository('AcfDataBundle:Role')->findOneBy(array('name' => 'ROLE_CLIENT1'));
                     $users = array();
                     foreach ($company->getUsers() as $user) {
                         if ($user->hasRole($acfCloudRole)) {
                             $users[] = $user;
                         }
                     }
                     if (\count($users) != 0) {
                         foreach ($users as $user) {
                             $mvars = array();
                             $mvars['company'] = $company;
                             $mvars['docs'] = $docs;
                             $message = \Swift_Message::newInstance();
                             $message->setFrom($from, $fromName);
                             $message->addTo($user->getEmail(), $user->getFullname());
                             $message->setSubject($subject);
                             $mvars['logo'] = $message->embed(\Swift_Image::fromPath($this->getParameter('kernel.root_dir') . '/../web/bundles/acfres/images/logo_acf.jpg'));
//.........这里部分代码省略.........
开发者ID:sasedev,项目名称:acf-expert,代码行数:101,代码来源:CustomerController.php


示例20: embedImages

 /**
  * embed images to the given body
  *
  * @param  string $body
  * @return string
  */
 protected function embedImages($body)
 {
     foreach ($this->embedded as $image) {
         if (false !== strpos($body, $this->embeddedUrl . $image)) {
             $cid = $this->message->embed(Swift_Image::fromPath($this->embeddedDir . $image));
             $body = str_replace($this->embeddedUrl . $image, $cid, $body);
         }
     }
     return $body;
 }
开发者ID:blerou,项目名称:SimpleMail,代码行数:16,代码来源:SwiftSender.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Swift_InputByteStream类代码示例发布时间:2022-05-23
下一篇:
PHP Swift_Events_SendEvent类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap