function execute()
 {
     global $REX;
     $template_name = $this->getElement(2);
     if ($etpl = rex_xform_emailtemplate::getTemplate($template_name)) {
         // ----- find mailto
         $mail_to = $REX['ERROR_EMAIL'];
         // default
         // finde email label in list
         if ($this->getElement(3) != false && $this->getElement(3) != '') {
             foreach ($this->params['value_pool']['email'] as $key => $value) {
                 if ($this->getElement(3) == $key) {
                     $mail_to = $value;
                 }
                 break;
             }
         }
         // ---- fix mailto from definition
         if ($this->getElement(4) != false && $this->getElement(4) != '') {
             $mail_to = $this->getElement(4);
         }
         $etpl = rex_xform_emailtemplate::replaceVars($etpl, $this->params['value_pool']['email']);
         $etpl['mail_to'] = $mail_to;
         $etpl['mail_to_name'] = $mail_to;
         if ($etpl['attachments'] != '') {
             $f = explode(',', $etpl['attachments']);
             $etpl['attachments'] = array();
             foreach ($f as $v) {
                 $etpl['attachments'][] = array('name' => $v, 'path' => $REX['INCLUDE_PATH'] . '/../../files/' . $v);
             }
         } else {
             $etpl['attachments'] = array();
         }
         if ($this->params['debug']) {
             echo '<hr /><pre>';
             var_dump($etpl);
             echo '</pre><hr />';
         }
         if (!rex_xform_emailtemplate::sendMail($etpl, $template_name)) {
             echo 'error - email sent';
             return false;
         } else {
             return true;
         }
     }
     return false;
 }
 function execute()
 {
     global $REX;
     $template_name = $this->getElement(2);
     if ($etpl = rex_xform_emailtemplate::getTemplate($template_name)) {
         // ----- find mailto
         $mail_to = $REX['ERROR_EMAIL'];
         // default
         // finde email label in list
         if ($this->getElement(3) != FALSE && $this->getElement(3) != "") {
             foreach ($this->elements_email as $key => $value) {
                 if ($this->action["elements"][3] == $key) {
                     $mail_to = $value;
                     break;
                 }
             }
         }
         // ---- fix mailto from definition
         if ($this->getElement(4) != FALSE && $this->getElement(4) != "") {
             $mail_to = $this->getElement(4);
         }
         $etpl = rex_xform_emailtemplate::replaceVars($etpl, $this->elements_email);
         $etpl['mail_to'] = $mail_to;
         $etpl['mail_to_name'] = $mail_to;
         if ($etpl['attachments'] != "") {
             $f = explode(",", $etpl['attachments']);
             $etpl['attachments'] = array();
             foreach ($f as $v) {
                 $etpl['attachments'][] = array("name" => $v, "path" => $REX["INCLUDE_PATH"] . '/../../files/' . $v);
             }
         } else {
             $etpl['attachments'] = array();
         }
         if ($this->params["debug"]) {
             echo "<hr /><pre>";
             var_dump($etpl);
             echo "</pre><hr />";
         }
         if (!rex_xform_emailtemplate::sendMail($etpl)) {
             echo "Fehler beim E-Mail Versand";
             return FALSE;
         }
         return TRUE;
     }
     return FALSE;
 }
 function replaceVars($template, $er = array())
 {
     global $REX;
     $er['REX_SERVER'] = $REX['SERVER'];
     $er['REX_ERROR_EMAIL'] = $REX['ERROR_EMAIL'];
     $er['REX_SERVERNAME'] = $REX['SERVERNAME'];
     $er['REX_NOTFOUND_ARTICLE_ID'] = $REX['NOTFOUND_ARTICLE_ID'];
     $er['REX_ARTICLE_ID'] = $REX['ARTICLE_ID'];
     foreach ($er as $search => $replace) {
         foreach ($template as $k => $v) {
             $template[$k] = str_replace('###' . $search . '###', $replace, $template[$k]);
             $template[$k] = str_replace('***' . $search . '***', urlencode($replace), $template[$k]);
             $template[$k] = str_replace('+++' . $search . '+++', rex_xform_emailtemplate::makeSingleLine($replace), $template[$k]);
         }
     }
     return $template;
 }