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


PHP Swift_Message::setContentType方法代码示例

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


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

示例1: buildMessage

 /**
  * (non-PHPdoc)
  * @see AppCommon\CommonMailBundle.MailBuilder::buildMessage()
  */
 public function buildMessage($body, $subject, $recipient = null)
 {
     $message = new \Swift_Message();
     $message->setFrom($this->container->getParameter('mailer_sender'), $this->container->getParameter('mailer_sender_name'));
     $message->setSubject($subject);
     $message->setBody($body);
     $message->setContentType('text/html');
     if (null !== $recipient) {
         $message->setTo($recipient);
     }
     return $message;
 }
开发者ID:amin1984,项目名称:Behat,代码行数:16,代码来源:DefaultMailBuilder.php

示例2: sendMail

 /**
  * {@inheritdoc}
  */
 public function sendMail($subject, $body, $toMail = null, $fromMail = null, $html = true)
 {
     $message = new \Swift_Message($subject, $body);
     if (!$toMail) {
         $toMail = $this->toMail;
     }
     if (!$fromMail) {
         $fromMail = $this->fromMail;
     }
     if ($html) {
         $message->setContentType('text/html');
     }
     $message->setFrom($fromMail);
     $message->setTo($toMail);
     $this->logger->info(sprintf('Try register mail from L91 FormBundle: ' . PHP_EOL . '   From: ' . $fromMail . PHP_EOL . '   To: ' . $toMail . PHP_EOL . '   Subject: ' . $subject));
     return $this->mailer->send($message);
 }
开发者ID:dominikmatt,项目名称:sulu-form-bundle,代码行数:20,代码来源:Helper.php

示例3: processEmail

    /**
     * Prepare the email message.
     */
    public function processEmail()
    {
        $this->count = 1;
        $mail = new Swift_Message();
        $mail->setContentType('text/plain');
        $mail->setCharset('utf-8');
        if ($this->getOption('use_complete_template', true)) {
            $mail->setBody(sprintf(<<<EOF
------
%s - %s
------
%s
------
EOF
, $this->options['name'], $this->options['email'], $this->options['message']));
        } else {
            $mail->setBody($this->options['message']);
        }
        $mail->setSender(array(sfPlop::get('sf_plop_messaging_from_email') => sfPlop::get('sf_plop_messaging_from_name')));
        $mail->setFrom(array($this->options['email'] => $this->options['name']));
        if ($this->getOption('copy')) {
            $mail->setCc(array($this->options['email'] => $this->options['name']));
            $this->count++;
        }
        if (is_integer($this->getOption('receiver'))) {
            $receiver = sfGuardUserProfilePeer::retrieveByPK($this->getOption('receiver'));
            if ($receiver) {
                $mail->setTo(array($receiver->getEmail() => $receiver->getFullName()));
            } else {
                $mail->setTo(array(sfPlop::get('sf_plop_messaging_to_email') => sfPlop::get('sf_plop_messaging_to_name')));
            }
        } else {
            $mail->setTo(array(sfPlop::get('sf_plop_messaging_to_email') => sfPlop::get('sf_plop_messaging_to_name')));
        }
        if ($this->getOption('subject')) {
            $mail->setSubject($this->getOption('subject'));
        } else {
            $mail->setSubject(sfPlop::get('sf_plop_messaging_subject'));
        }
        $this->mail = $mail;
    }
开发者ID:noreiller,项目名称:sfPlopPlugin,代码行数:44,代码来源:sfPlopMessaging.class.php

示例4: streamToMime

 /**
  * Merges an OutputByteStream to Swift_Message.
  *
  * @param Swift_OutputByteStream $fromStream
  * @param Swift_Message          $message
  */
 protected function streamToMime(Swift_OutputByteStream $fromStream, Swift_Message $message)
 {
     $bufferLength = 78;
     $headerData = '';
     $fromStream->setReadPointer(0);
     while (($buffer = $fromStream->read($bufferLength)) !== false) {
         $headerData .= $buffer;
         if (false !== strpos($buffer, "\r\n\r\n")) {
             break;
         }
     }
     $headersPosEnd = strpos($headerData, "\r\n\r\n");
     $headerData = trim($headerData);
     $headerData = substr($headerData, 0, $headersPosEnd);
     $headerLines = explode("\r\n", $headerData);
     unset($headerData);
     $headers = array();
     $currentHeaderName = '';
     foreach ($headerLines as $headerLine) {
         // Line separated
         if (ctype_space($headerLines[0]) || false === strpos($headerLine, ':')) {
             $headers[$currentHeaderName] .= ' ' . trim($headerLine);
             continue;
         }
         $header = explode(':', $headerLine, 2);
         $currentHeaderName = strtolower($header[0]);
         $headers[$currentHeaderName] = trim($header[1]);
     }
     $messageStream = new Swift_ByteStream_TemporaryFileByteStream();
     $messageStream->addFilter($this->replacementFactory->createFilter("\r\n", "\n"), 'CRLF to LF');
     $messageStream->addFilter($this->replacementFactory->createFilter("\n", "\r\n"), 'LF to CRLF');
     $messageHeaders = $message->getHeaders();
     // No need to check for 'application/pkcs7-mime', as this is always base64
     if ('multipart/signed;' === substr($headers['content-type'], 0, 17)) {
         if (!preg_match('/boundary=("[^"]+"|(?:[^\\s]+|$))/is', $headers['content-type'], $contentTypeData)) {
             throw new Swift_SwiftException('Failed to find Boundary parameter');
         }
         $boundary = trim($contentTypeData['1'], '"');
         $boundaryLen = strlen($boundary);
         // Skip the header and CRLF CRLF
         $fromStream->setReadPointer($headersPosEnd + 4);
         while (false !== ($buffer = $fromStream->read($bufferLength))) {
             $messageStream->write($buffer);
         }
         $messageStream->commit();
         $messageHeaders->remove('Content-Transfer-Encoding');
         $message->setContentType($headers['content-type']);
         $message->setBoundary($boundary);
         $message->setBody($messageStream);
     } else {
         $fromStream->setReadPointer($headersPosEnd + 4);
         if (null === $this->headerFactory) {
             $this->headerFactory = Swift_DependencyContainer::getInstance()->lookup('mime.headerfactory');
         }
         $message->setContentType($headers['content-type']);
         $messageHeaders->set($this->headerFactory->createTextHeader('Content-Transfer-Encoding', $headers['content-transfer-encoding']));
         $messageHeaders->set($this->headerFactory->createTextHeader('Content-Disposition', $headers['content-disposition']));
         while (false !== ($buffer = $fromStream->read($bufferLength))) {
             $messageStream->write($buffer);
         }
         $messageStream->commit();
         $message->setBody($messageStream);
     }
 }
开发者ID:NivalM,项目名称:VacantesJannaMotors,代码行数:70,代码来源:SMimeSigner.php

示例5: createMessage

 /**
  * @param $subject
  * @return $this
  */
 public function createMessage($subject)
 {
     $this->message = \Swift_Message::newInstance($subject);
     $this->message->setContentType("test/html");
     return $this;
 }
开发者ID:semplon,项目名称:mabes,代码行数:10,代码来源:MailerService.php

示例6: addInlineImagesToMessage

 protected function addInlineImagesToMessage(\Swift_Message &$message, $fieldhtml)
 {
     $regex = '~data:[^;]+;[A-Za-z0-9]+,[^")\'\\s]+~';
     preg_match_all($regex, $fieldhtml, $treffers, PREG_OFFSET_CAPTURE);
     $treffers = $treffers[0];
     foreach ($treffers as $treffer) {
         $trefferexpl = explode(',', $treffer[0], 2);
         $data = explode(';', $trefferexpl[0]);
         $data = explode(':', $data[0]);
         $mimetype = $data[1];
         $decoded = base64_decode($trefferexpl[1]);
         $image = new \Swift_Image();
         $image->setBody($decoded, $mimetype);
         $cid = $message->embed($image);
         $fieldhtml = str_replace($treffer[0], $cid, $fieldhtml);
     }
     $message->setContentType("text/html")->setBody($fieldhtml, 'text/html');
     return true;
 }
开发者ID:julianstricker,项目名称:xxam,代码行数:19,代码来源:MailclientBaseController.php

示例7: inviteNewUser

 private function inviteNewUser($email, $mailer)
 {
     $username = md5(rand(1000, 9999));
     $password = md5(rand(1000, 9999));
     $user = new sfGuardUser();
     $user->username = $username;
     $user->password = $password;
     $user->groups[] = Doctrine::getTable('sfGuardGroup')->createQuery('a')->where('a.name = ?', 'leerling')->fetchOne();
     $user->Profile = new sfGuardUserProfile();
     $user->Profile->email = $email;
     $user->Profile->is_invite = true;
     $user->save();
     $user->Profile->save();
     $name = sprintf('%s (%s)', $this->getUser()->getGuardUser()->getFullname(), $this->getUser()->getUsername());
     $url = $this->getController()->genUrl(sprintf('@invite_accept?username=%s', $username), true);
     $message = new Swift_Message();
     $message->setFrom('DNS Leergemeenschap Site');
     $message->setSubject('Uitnodiging DNS Leergemeenschap');
     $message->setContentType('text/html');
     $message->setBody("Hallo, <br /><br />\n\nJij bent door {$name} uitgenodigd om deel te nemen aan de de DNS Leergemeenschap site.<br /><br />\n\n<a href=\"{$url}\">Klik hier om de uitnodiging aan te nemen</a><br /><br /><br /><br /><br /><br />\n\n{$url}");
     $recipients = new Swift_RecipientList();
     foreach (sfConfig::get('app_feedback_feedback_email', array('dnsleergemeenschap@gmail.com')) as $recipient) {
         $recipients->addTo($recipient);
     }
     $mailer->send($message, $recipients, $this->getUser()->getEmail());
 }
开发者ID:robinkanters,项目名称:dnsleergemeenschap,代码行数:26,代码来源:actions.class.php

示例8: backup_module_log_error

/**
 * Send error log to administrator
 *
 * @param array $errors
 * @return boolean
 */
function backup_module_log_error($errors, $send_email = false)
{
    $log_message = is_foreachable($errors) ? implode("\n", $errors) : $errors;
    if ($send_email) {
        $mailer =& ApplicationMailer::mailer();
        $recipient = new Swift_Address();
        $recipient->setAddress(ADMIN_EMAIL);
        $recipient->setName('activeCollab admin');
        $sender = new Swift_Address();
        $sender->setAddress(ConfigOptions::getValue('notifications_from_email'));
        $sender->setName(ConfigOptions::getValue('notifications_from_name'));
        $tmp_message = "Automatic backup of activeCollab on " . ROOT_URL . " failed.\n\r";
        $tmp_message .= "Backup returned these errors: \n\r\n\r";
        $tmp_message .= $log_message;
        $message = new Swift_Message();
        $message->setSubject('activeCollab automatic backup error log');
        $message->setData($tmp_message);
        $message->setContentType('text/plain');
        $mailer->send($message, $recipient, $sender);
    }
    // if
    log_message($log_message, LOG_LEVEL_ERROR, 'backup');
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:29,代码来源:init.php

示例9: setContentType

 /**
  * {@inheritdoc}
  *
  * @return $this|self
  */
 public function setContentType($type) : self
 {
     $this->message->setContentType($type);
     return $this;
 }
开发者ID:cawaphp,项目名称:email,代码行数:10,代码来源:Message.php

示例10: setContentType

 /**
  * Specifies the format of the message (usually text/plain or text/html).
  *
  * @param string $contentType
  *
  * @return $this
  */
 public function setContentType($contentType)
 {
     $this->message->setContentType($contentType);
     return $this;
 }
开发者ID:Webiny,项目名称:Framework,代码行数:12,代码来源:Message.php


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