Save email template to database.
779210
public function saveEmailTemplate()
    {
        if (null === $this->_template->key) {
            $this->_template->key = $this->generateKey();
        }

        $this->_repository->save($this->_template);
    }
816097
def dbtemplate_save(sender, instance, created, **kwargs):
    

    if created:
        if 'widget' in instance.name:
            name = instance.name.split('/')[-1]
            kwargs = {
                'name': name.split('.')[0],
                'label': name.split('.')[0].capitalize(),
                'template': instance,
            }
            if 'base/widget' in instance.name:
                from leonardo.module.web.models import WidgetBaseTheme
                theme_cls = WidgetBaseTheme
            else:
                from leonardo.module.web.models import WidgetContentTheme
                theme_cls = WidgetContentTheme
                from leonardo.utils.widgets import find_widget_class
                w_cls_name = instance.name.split('/')[-2]
                w_cls = find_widget_class(w_cls_name)
                if w_cls is None:
                    raise Exception('widget class for %s not found' % w_cls_name)
                kwargs['widget_class'] = w_cls.__name__
            theme_cls(**kwargs).save()

        if 'base/page' in instance.name:
            from leonardo.module.web.models import PageTheme
            page_theme = PageTheme()
            page_theme.label = '{} layout'.format(
                instance.name.split("/")[-1].split('.')[0].title())
            page_theme.name = instance.name.split("/")[-1]
            page_theme.template = instance
            page_theme.save()
1138416
def template(cls, address=None, commandtuple=None,
                 userdata=None, cmd2=-1, flags=None, acknak=None):
        """"""
        msgraw = bytearray([0x02, cls._code])
        msgraw.extend(bytes(cls._receivedSize))
        msg = ExtendedSend.from_raw_message(msgraw)

        if commandtuple:
            cmd1 = commandtuple.get('cmd1')
            cmd2out = commandtuple.get('cmd2')
        else:
            cmd1 = None
            cmd2out = None

        if cmd2 is not -1:
            cmd2out = cmd2

        msg._address = Address(address)
        msg._messageFlags = MessageFlags(flags)
        msg._messageFlags.extended = 1
        msg._cmd1 = cmd1
        msg._cmd2 = cmd2out
        msg._userdata = Userdata.template(userdata)
        msg._acknak = acknak
        return msg
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)
686263
def process_template(self, sql, **kwargs):
        
        template = self.env.from_string(sql)
        kwargs.update(self.context)
        return template.render(kwargs)
1096416
def save_form(self, request, form, change):
        """"""
        instance = super(PageAdmin, self).save_form(request, form, change)
        instance.template = form.cleaned_data['template']
        if not change:
            instance.author = request.user
        return instance
512020
protected void save() {

        boolean newUser = false;
        try {
            if (m_user == null) {
                createNewUser();
                newUser = true;
            } else {

                saveUser();
            }
            saveUserSettings();
            if (m_sendEmail.getValue().booleanValue() & m_sendEmail.isEnabled()) {
                sendMail(m_cms, m_pw.getPassword1(), m_user, newUser, m_forceResetPassword.getValue().booleanValue());
            }
        } catch (CmsException e) {
            LOG.error("Unable to save user", e);
        }
    }
319539
public function fetchEmailTemplate()
    {
        if (null !== $this->owner) {
            $this->_template = $this->_repository->getByKeyWithTranslation(
                $this->generateKey(),
                $this->owner->{$this->_languageAttribute}
            );
        } else {
            $this->_template = $this->_repository->create();
        }
    }
38703
def email_template(rcpt, template_path, **kwargs):
    

    subject, content = parse_template(template_path, **kwargs)
    count = send_mail(subject, content, settings.DEFAULT_FROM_EMAIL,
                      [rcpt], fail_silently=True)
    return bool(count)
1280055
def add_template_for_node(name, node_id):
    ""
    with current_app.app_context():
        db.execute(text(fetch_query_string('insert_template.sql')),
                name=name, node_id=node_id)
        result = db.execute(text(fetch_query_string('select_template.sql')),
                          name=name, node_id=node_id).fetchall()
        if result:
            template_id = result[0]['id']
            db.execute(text(fetch_query_string('update_template_node.sql')),
                    template=template_id, node_id=node_id)
700122
def save(self):
        
        while True:
            username = sha1(str(random.random()).encode('utf-8')).hexdigest()[:5]
            try:
                get_user_model().objects.get(username__iexact=username)
            except get_user_model().DoesNotExist: break

        self.cleaned_data['username'] = username
        return super(SignupFormOnlyEmail, self).save()
468494
def save_user_and_user_email(self, user, user_email):
        """"""
        if self.UserEmailClass:
            self.db_adapter.save_object(user_email)
        self.db_adapter.save_object(user)
887977
def save_model(self, request, obj, form, change):
        
        email = message.EmailMessage(
            subject=obj.subject,
            body=obj.body,
            from_email=obj.from_email,
            to=[t.strip() for t in obj.to_emails.split(',')],
            bcc=[t.strip() for t in obj.bcc_emails.split(',')],
            cc=[t.strip() for t in obj.cc_emails.split(',')]
        )
        email.send()
241231
public function sample1()
   {
      $data = null;
      $template_html = 'sample-1.html';

      $mail = new Mail();
      $mail->setMailBody($data, $template_html);
      $mail->sendMail('Test Sample 1 - external HTML template');
      exit('Message Sent!');
   }
409859
def set_email(self, email, _vars=None, lists=None, templates=None, verified=0, optout=None, send=None, send_vars=None):
        
        _vars = _vars or {}
        lists = lists or []
        templates = templates or []
        send_vars = send_vars or []
        data = {'email': email,
                'vars':  _vars.copy(),
                'lists': lists,
                'templates': templates,
                'verified': int(verified)}
        if optout is not None:
            data['optout'] = optout
        if send is not None:
            data['send'] = send
        if send_vars:
            data['send_vars'] = send_vars
        return self.api_post('email', data)
1154533
public static function sendNewMessage($email, $templateId, $templateParams = [])
    {
        $email = explode(',', $email);
        foreach ((array) $email as $singleEmail) {
            $message = new Message;
            $message->attributes = [
                'email' => trim($singleEmail),
                'template_id' => $templateId,
                'packed_json_template_params' => Json::encode($templateParams),
                'status' => Message::STATUS_NEW,
            ];
            if ($message->save()) {
                static::runTask(
                    [
                        realpath(Yii::getAlias('@app') . '/yii'),
                        'emails/send',
                        $message->id,
                    ],
                    Module::DEFERRED_TASK_GROUP_MESSAGE_SEND
                );
            }
        }
    }
708992
def render_mail(self, template_prefix, email, context):
        
        subject = render_to_string('{0}_subject.txt'.format(template_prefix),
                                   context)
        # remove superfluous line breaks
        subject = " ".join(subject.splitlines()).strip()
        subject = self.format_email_subject(subject)

        bodies = {}
        for ext in ['html', 'txt']:
            try:
                template_name = '{0}_message.{1}'.format(template_prefix, ext)
                bodies[ext] = render_to_string(template_name,
                                               context).strip()
            except TemplateDoesNotExist:
                if ext == 'txt' and not bodies:
                    # We need at least one body
                    raise
        if 'txt' in bodies:
            msg = EmailMultiAlternatives(subject,
                                         bodies['txt'],
                                         settings.DEFAULT_FROM_EMAIL,
                                         [email])
            if 'html' in bodies:
                msg.attach_alternative(bodies['html'], 'text/html')
        else:
            msg = EmailMessage(subject,
                               bodies['html'],
                               settings.DEFAULT_FROM_EMAIL,
                               [email])
            msg.content_subtype = 'html'  # Main content is now text/html
        return msg