Send a preview email
185462
def preview_to(recipient)
      @newsletter = build_newsletter
      mail = build_mail
      mail.to = recipient.email
      replace_and_send_mail_safely(mail, recipient)
    end
104137
def sendmail_proxy(subject, email, template, **context):
    """"""
    sendmail.delay(subject.value, email, template, **context)
923535
def send_email(name, ctx_dict, send_to=None, subject=u'Subject', **kwargs):
    

    eft = EmailFromTemplate(name=name)
    eft.subject = subject
    eft.context = ctx_dict
    eft.get_object()
    eft.render_message()
    eft.send_email(send_to=send_to, **kwargs)
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;
    }
323608
def send_email_template(slug, base_url=None, context=None, user=None,
                       to=None, cc=None, bcc=None, attachments=None, headers=None, connection=None, fail_silently=False):
    
    email_template = EmailTemplate.objects.get_for_slug(slug)

    email = email_template.get_email_message(
        base_url, context, user,
        to=to, cc=cc, bcc=bcc,
        attachments=attachments, headers=headers, connection=connection
    )

    return email.send(fail_silently=fail_silently)
1002684
def send_mail_template(subject, template, addr_from, recipient_list,
                       fail_silently=False, attachments=None, context=None,
                       connection=None, headers=None):
    

    if context is None:
        context = {}

    # Loads a template passing in vars as context.
    def render(ext):
        name = "email_extras/%s.%s" % (template, ext)
        return loader.get_template(name).render(context)

    send_mail(subject, render("txt"), addr_from, recipient_list,
              fail_silently=fail_silently, attachments=attachments,
              html_message=render("html"), connection=connection,
              headers=headers)
975654
def preview_email_marketing_campaign(self, email_marketing_campaign):
        
        url = self.api.join('/'.join([
            self.EMAIL_MARKETING_CAMPAIGN_URL,
            str(email_marketing_campaign.constant_contact_id),
            'preview']))
        response = url.get()
        self.handle_response_status(response)
        return (response.json()['preview_email_content'],
                response.json()['preview_text_content'])
608440
protected function definition_preview() {
        foreach ($this->structure->get_items() as $feedbackitem) {
            $itemobj = feedback_get_item_class($feedbackitem->typ);
            $itemobj->complete_form_element($feedbackitem, $this);
        }
    }
794881
function it_generates_the_expected_request_when_previewing_a_template(){

        //---------------------------------
        // Test Setup

        $id = self::SAMPLE_ID;
        $body = [
            'personalisation' => [
                'name'=>'Fred'
            ]
        ];

        $this->httpClient->sendRequest( Argument::type('Psr\Http\Message\RequestInterface') )->willReturn(
            new Response(
                201,
                [ 'Content-type'  => 'application/json' ],
                '{}'
            )
        );

        //---------------------------------
        // Perform action

        $this->previewTemplate( $id, $body['personalisation']);

        //---------------------------------
        // Check result

        $this->httpClient->sendRequest( Argument::that(function( $v ) use ($id, $body) {
            // With the correct URL
            if( $v->getUri() != self::BASE_URL . sprintf( Client::PATH_TEMPLATE_PREVIEW, $id ) ){
                return false;
            }

            // With the expected body.
            if( json_decode( $v->getBody(), true ) != $body ){
                return false;
            }

            return true;

        }))->shouldHaveBeenCalled();

    }
796022
def send_msg(template_id, to, reply_to, from, subject, optional = {})

      if optional[:attachments]
        upload(template_id, to, reply_to, from, subject, optional[:merge_fields], optional[:view_online], optional[:click_tracking],
               optional[:suppress_address], optional[:attachments], optional[:headers], optional[:reply_name], optional[:from_address])
      else
        params =  optional ? optional.clone : {}
        params[:template_id] =  template_id
        params[:to] =  to
        params[:reply_to] =  reply_to
        params[:from] =  from
        params[:subject] =  subject

        post @endpoint, params
      end
    end
511676
public function previewBlastWithHTML($blast_id, $email) {
        $data = [ ];
        $data['blast_id'] = $blast_id;
        $data['email'] = $email;

        $result = $this->apiPost('preview', $data);
        return $result;
    }
984860
def preview_text
      res = result
      [label, res.strip] unless res.nil? || res.empty?
    end
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);
    }
678703
public function previewRecurringBlastWithHTML($blast_repeat_id, $email) {
        $data = [ ];
        $data['blast_repeat_id'] = $blast_repeat_id;
        $data['email'] = $email;

        $result = $this->apiPost('preview', $data);
    }
666586
public function preview() {
    if ($this->uuid) {
      $this->_save(Recurly_Client::POST, $this->uri() . '/preview');
    } else {
      $this->_save(Recurly_Client::POST, Recurly_Client::PATH_SUBSCRIPTIONS . '/preview');
    }
  }
682541
def preview(file):
    """"""
    return render_template(
        'invenio_previewer/xml_prismjs.html',
        file=file,
        content=render(file),
        js_bundles=['previewer_prism_js'],
        css_bundles=['previewer_prism_css'],
    )
274442
def preview(self, path=None, extra_context=None, publish=False):
        
        try:
            self.call_hook("preview", self)

            if path is None:
                path = 'index.html'

            # Detect files
            filepath, mimetype = self._resolve_path(path)

            # Serve dynamic
            if filepath and mimetype and mimetype in self.project.TEMPLATE_TYPES:
                context = self.get_context(publish)
                context.update({
                    "PATH": path,
                    "PREVIEW_SERVER": not publish,
                    "TIMESTAMP": int(time.time()),
                })
                if extra_context:
                    context.update(extra_context)

                rendered = render_template(path, **context)
                return Response(rendered, mimetype=mimetype)

            # Serve static
            if filepath:
                dir, filename = os.path.split(filepath)
                return send_from_directory(dir, filename)

        except Exception as e:
            ex_type, ex, tb = sys.exc_info()
            try:
                # Find template with name of error
                cls = e.__class__
                ex_type, ex, tb = sys.exc_info()

                context = self.project.DEFAULT_CONTEXT
                context.update({
                    'PATH': path,
                    'traceback': traceback.format_exception(ex_type, ex, tb),
                    'e': e,
                })
                if extra_context:
                    context.update(extra_context)

                try:
                    error_path = '_{0}.{1}.html'.format(cls.__module__, cls.__name__)
                    rendered = render_template(error_path, **context)
                except TemplateNotFound:
                    # Find template without underscore prefix, @TODO remove in v1.1
                    error_path = '{0}.{1}.html'.format(cls.__module__, cls.__name__)
                    rendered = render_template(error_path, **context)

                return Response(rendered, mimetype="text/html")
            except TemplateNotFound:
                # Otherwise raise old error
                reraise(ex_type, ex, tb)

        # Last ditch effort -- see if path has "index.html" underneath it
        if not path.endswith("index.html"):
            if not path.endswith("/"):
                path = "{0}/".format(path)
            path = "{0}{1}".format(path, "index.html")
            return self.preview(path)

        # It's a 404
        if path.endswith('/index.html'):
            path = path[:-11]
        rendered = render_template("404.html", PATH=path)
        return Response(rendered, status=404)