Get an email preview of content_html.
@param $content_html
@param $send_email
@return array
@link http://docs.sailthru.com/api/preview
493751
public function previewContentWithEmail($content_html, $send_email) {
        $data = [ ];
        $data['content_html'] = $content_html;
        $data['send_email'] = $send_email;

        $result = $this->apiPost('preview', $data);
        return $result;
    }
142695
public function getHtmlStream($index = 0, $charset = MailMimeParser::DEFAULT_CHARSET)
    {
        $htmlPart = $this->getHtmlPart($index);
        if ($htmlPart !== null) {
            return $htmlPart->getContentStream($charset);
        }
        return null;
    }
473186
public static function sendMail($recipient, $subject = null, $html, $c = null)
    {
        $c = self::toArray($c);
        $headers = 'From: ' . stripslashes($c['exp_nom']) . ' <' . $c['exp_mail'] . '>' . "\r\n";
        $headers .= 'MIME-version: 1.0' . "\n";
        $headers .= 'Content-type: text/html; charset=UTF-8' . "\n";
        $headers .= 'Reply-To: ' . $c['exp_mail'] . "\r\n";
        $success = mail($recipient, '=?UTF-8?B?' . base64_encode($subject) . '?=', stripslashes($html), $headers);

        return $success;
    }
1320802
public function preview()
    {
        $inputs  = Input::all();
        $content = str_replace("&#39;", '"', $inputs['content']);
        $content = $this->variablesAdapter->get($content);

        if( isset($inputs['subject']) ) {
            $subject = str_replace("&#39;", '"', $inputs['subject']);
            $subject = $this->variablesAdapter->get($subject);

            array_set($inputs, 'subject', $subject);
        }

        preg_match_all('/\[\[(.*?)\]\]/', $content, $matches);
        $view = str_replace($matches[0], $matches[1], $content);

        if (array_get($inputs, 'type') === 'email') {
            event('antares.notifier.before_send_email', [&$view]);
        }

        $brandTemplate = BrandOptions::query()->where('brand_id', brand_id())->first();
        $header        = str_replace('</head>', '<style>' . $brandTemplate->styles . '</style></head>', $brandTemplate->header);
        $html          = preg_replace("/<body[^>]*>(.*?)<\/body>/is", '<body>' . $view . '</body>', $header . $brandTemplate->footer);

        array_set($inputs, 'content', $html);

        return $this->presenter->preview($inputs);
    }
867188
public function previewRecurringBlastWithEmail($blast_repeat_id, $send_email) {
        $data = [ ];
        $data['blast_repeat_id'] = $blast_repeat_id;
        $data['send_email'] = $send_email;

        $result = $this->apiPost('preview', $data);
        return $result;
    }
1197526
protected function getMailData($sTpl, array $aVars = [])
    {
        $sSubject = $sHtml = $sPlain = null;

        $aTplData = explode('######', $this->renderMail($sTpl, $aVars));
        $aTplData = array_map('trim', $aTplData);

        foreach ($aTplData as $sRow) {
            $aParts = array_map('trim', explode(':', $sRow, 2));

            switch (strtolower($aParts[0])) {
                case 'subject':
                    $sSubject = $aParts[1];
                    break;

                case 'html':
                    $sHtml = $aParts[1];
                    break;

                case 'plain':
                    $sPlain = $aParts[1];
                    break;

                default:
            }
        }

        if ($sSubject === null) {
            $sSubject = 'Missing subject';
        }

        if ($sHtml === null) {
            $sHtml = 'Missing html content';
        }

        if ($sPlain === null) {
            $oHtmlConverter = $this->getHtml2Text();
            $oHtmlConverter->setHtml($sHtml);
            $sPlain = $oHtmlConverter->getText();
        }

        return [
            'subject' => $sSubject,
            'html' => $sHtml,
            'plain' => $sPlain,
        ];
    }
752569
public function preview()
	{
		$selector = 'ctrl_textarea' . $this->id;

		$strPreview = '<div class="widget" style="padding-top:10px;"><h3 style="margin: 0;"><label>' . $this->label . '</label></h3>';
		$strPreview .= '<textarea id="' . $selector . '" aria-hidden="true" class="tl_textarea noresize" rows="12" cols="80"></textarea>';
		
		// Register all tinyMCE template files
		if (!array_key_exists($this->rteTemplate, TemplateLoader::getFiles()))
		{
			$objFilesystem = new Filesystem();
			
			$arrTemplateFiles = glob(TL_ROOT . '/templates/*/be_tinyMCE*');

			foreach ($arrTemplateFiles as $strFile)
			{
				$arrTemplates[basename($strFile, '.html5')] = rtrim($objFilesystem->makePathRelative(dirname($strFile), TL_ROOT), '/');
			}
			
			if ($arrTemplates !== null)
			{
				TemplateLoader::addFiles($arrTemplates);
			}
		}

		if (array_key_exists($this->rteTemplate, TemplateLoader::getFiles()))
		{
			$objTemplate = new \BackendTemplate($this->rteTemplate);
			$objTemplate->selector = $selector;

			$strPreview .= $objTemplate->parse();
		}
			
		$strPreview .= '<p title="" class="tl_help tl_tip">' . $this->description . '</p></div>';	

		return $strPreview;
	}
869472
def send_html(self, html, body=None, msgtype="m.text"):
        
        return self.client.api.send_message_event(
            self.room_id, "m.room.message", self.get_html_content(html, body, msgtype))
1087839
private function getRecomText($content_area)
    {
        $text = $content_area->find('.borderClass', 0)->find('.spaceit_pad', 0)->plaintext;
        $useless_area = $content_area->find('.js-toggle-recommendation-button', 0) ? $content_area->find('.js-toggle-recommendation-button', 0)->plaintext : null;
        $text = str_replace($useless_area, '', $text);
        $text = str_replace('&lt;', '<', $text);
        $text = preg_replace('/\s{2,}/', "\n", $text);

        return $text;
    }
1176752
public function newLaunch($send_name=true, $send_email=true) {
        $parms = array(
            'lti_message_type' => 'basic-lti-launch-request',
            'tool_consumer_info_product_family_code' => 'tsugi',
            'tool_consumer_info_version' => '1.1',
        );

        // Some Tsugi Goodness
        $form_id = "tsugi_form_id_".bin2Hex(openssl_random_pseudo_bytes(4));
        $parms['ext_lti_form_id'] = $form_id;

        if ( $this->user ) {
            $parms['user_id'] = $this->user->id;
            $parms['roles'] = $this->user->instructor ? 'Instructor' : 'Learner';
            if ( $send_name ) $parms['lis_person_name_full'] = $this->user->displayname;
            if ( $send_email ) $parms['lis_person_contact_email_primary'] = $this->user->email;
            if ( $send_email || $send_email ) $parms['image'] = $this->user->image;
        }
        if ( $this->context ) {
           $parms['context_id'] = $this->context->id;
           $parms['context_title'] = $this->context->title;
           $parms['context_label'] = $this->context->title;
        }
        if ( $this->link ) {
           $parms['resource_link_id'] = $this->link->id;
           $parms['resource_link_title'] = $this->link->title;
        }
        if ( $this->result ) {
           $parms['resource_link_id'] = $this->link->id;
           $parms['resource_link_title'] = $this->link->title;
        }
        foreach ( $parms as $k => $v ) {
            if ( $v === false || $v === null ) unset($parms[$k]);
        }
        return $parms;
    }
119104
public function previewBlastWithEmail($blast_id, $send_email) {
        $data = [ ];
        $data['blast_id'] = $blast_id;
        $data['send_email'] = $send_email;

        $result = $this->apiPost('preview', $data);
        return $result;
    }
564539
public function previewHTML($html)
    {
        $html = $this->parsingHtml->prepareHtml($html);

        $html = preg_replace('/<page([^>]*)>/isU', '<hr>Page : $1<hr><div$1>', $html);
        $html = preg_replace('/<page_header([^>]*)>/isU', '<hr>Page Header : $1<hr><div$1>', $html);
        $html = preg_replace('/<page_footer([^>]*)>/isU', '<hr>Page Footer : $1<hr><div$1>', $html);
        $html = preg_replace('/<\/page([^>]*)>/isU', '</div><hr>', $html);
        $html = preg_replace('/<\/page_header([^>]*)>/isU', '</div><hr>', $html);
        $html = preg_replace('/<\/page_footer([^>]*)>/isU', '</div><hr>', $html);

        $html = preg_replace('/<bookmark([^>]*)>/isU', '<hr>bookmark : $1<hr>', $html);
        $html = preg_replace('/<\/bookmark([^>]*)>/isU', '', $html);

        $html = preg_replace('/<barcode([^>]*)>/isU', '<hr>barcode : $1<hr>', $html);
        $html = preg_replace('/<\/barcode([^>]*)>/isU', '', $html);

        $html = preg_replace('/<qrcode([^>]*)>/isU', '<hr>qrcode : $1<hr>', $html);
        $html = preg_replace('/<\/qrcode([^>]*)>/isU', '', $html);

        echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>HTML View</title>
        <meta http-equiv="Content-Type" content="text/html; charset='.$this->_encoding.'" >
    </head>
    <body style="padding: 10px; font-size: 10pt;font-family:    Verdana;">
    '.$html.'
    </body>
</html>';
    }
561052
function(to,tmpName,obj,cb){
    fs.readFile(
      path.join(__dirname, 'emailBoiler.html'),
      'utf8',
      function(err, data) {
        if (err){
          return cb(err);
        }
        var tmp = cfg.templates[tmpName];
        var locals = {
          title: '',
          content: tmp.text,
        };

        var html = ejs.render(data, locals);
        obj.link = '<a href="' + obj.url + '">' + tmp.linkText + '</a>';
        html = ejs.render(html,obj);

        var subject = ejs.render(tmp.subject,obj);

        sendEmail(to,subject,html,cb);
      }
    );
  }
515980
def email(self, comment, content_object, request):
        
        if not self.email_notification:
            return
        recipient_list = [manager_tuple[1] for manager_tuple in settings.MANAGERS]
        t = loader.get_template('comments/comment_notification_email.txt')
        c = Context({ 'comment': comment,
                      'content_object': content_object })
        subject = '[%s] New comment posted on "%s"' % (get_current_site(request).name,
                                                          content_object)
        message = t.render(c)
        send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True)
711078
public static function parseContentType(string $content_type)
    {
        $directives = array_map('trim', explode(';', $content_type));

        $result = [
            'mime' => array_shift($directives)
        ];

        if (empty($directives)) {
            return $result['mime'];
        }

        foreach ($directives as $directive) {
            $parts = explode('=', $directive);
            $result[$parts[0]] = $parts[1];
        }

        return $result;
    }
144946
public function showHTML($result, $link_myself = true, $params = 'query=$0&amp;output=nice')
    {

        // adds links for HTML output

        $email_regex = "/([-_\w\.]+)(@)([-_\w\.]+)\b/i";
        $html_regex = "/(?:^|\b)((((http|https|ftp):\/\/)|(www\.))([\w\.]+)([,:%#&\/?~=\w+\.-]+))(?:\b|$)/is";
        $ip_regex = "/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/i";

        $out = '';
        $lempty = true;

        foreach ($result['rawdata'] as $line) {
            $line = trim($line);

            if ($line == '') {
                if ($lempty) {
                    continue;
                } else {
                    $lempty = true;
                }
            } else {
                $lempty = false;
            }

            $out .= $line . "\n";
        }

        if ($lempty) {
            $out = trim($out);
        }

        $out = strip_tags($out);
        $out = preg_replace($email_regex, '<a href="mailto:$0">$0</a>', $out);
        $out = preg_replace_callback(
            $html_regex,
            function ($matches) {
                if (substr($matches[0], 0, 4) == 'www.') {
                    $web = $matches[0];
                    $url = 'http://' . $web;
                } else {
                    $web = $matches[0];
                    $url = $web;
                }

                return '<a href="' . $url . '" target="_blank">' . $web . '</a>';
            },
            $out
        );

        if ($link_myself) {
            if ($params[0] == '/') {
                $link = $params;
            } else {
                $link = $_SERVER['PHP_SELF'] . '?' . $params;
            }

            $out = preg_replace($ip_regex, '<a href="' . $link . '">$0</a>', $out);

            if (isset($result['regrinfo']['domain']['nserver'])) {
                $nserver = $result['regrinfo']['domain']['nserver'];
            } else {
                $nserver = false;
            }

            if (isset($result['regrinfo']['network']['nserver'])) {
                $nserver = $result['regrinfo']['network']['nserver'];
            }

            if (is_array($nserver)) {
                reset($nserver);
                while (list($host, $ip) = each($nserver)) {
                    $url = '<a href="' . str_replace('$0', $ip, $link) . "\">$host</a>";
                    $out = str_replace($host, $url, $out);
                    $out = str_replace(strtoupper($host), $url, $out);
                }
            }
        }

        // Add bold field names
        $out = preg_replace("/(?m)^([-\s\.&;'\w\t\(\)\/]+:\s*)/", '<b>$1</b>', $out);

        // Add italics for disclaimer
        $out = preg_replace("/(?m)^(%.*)/", '<i>$0</i>', $out);

        return str_replace("\n", "<br/>\n", $out);
    }
652980
protected function get_content_type($mail_type, $boundary)
	{
		$related = $this->config['force_mixed'] ? 'multipart/mixed; ' : 'multipart/related; ';

		switch ($mail_type)
		{
			case 'plain':
				return 'text/plain';
			case 'plain_attach':
			case 'html_attach':
				return $related.$boundary;
			case 'html':
				return 'text/html';
			case 'html_alt_attach':
			case 'html_alt_inline_attach':
				return 'multipart/mixed; '.$boundary;
			case 'html_alt_inline':
			case 'html_alt':
			case 'html_inline':
				return 'multipart/alternative; '.$boundary;
			default:
				throw new \FuelException('Invalid content-type'.$mail_type);
		}
	}