Exemplo n.º 1
0
 function _SendEmail($s_to, $s_subj, $a_values, $b_use_template)
 {
     global $SPECIAL_VALUES;
     $a_headers = array();
     $s_mail_text = "";
     $s_from_addr = GetAROption("FromAddr");
     if (!isset($s_from_addr)) {
         $s_from_addr = "";
         if (!Settings::isEmpty('FROM_USER')) {
             if (Settings::get('FROM_USER') != "NONE") {
                 $s_from_addr = Settings::get('FROM_USER');
             }
         } else {
             global $SERVER;
             $s_from_addr = "FormMail@" . $SERVER;
         }
     } else {
         $s_from_addr = UnMangle($s_from_addr);
     }
     if (!empty($s_from_addr)) {
         $a_headers['From'] = SafeHeader($s_from_addr);
     }
     $s_type = "";
     if ($b_use_template) {
         if (IsAROptionSet('PlainTemplate')) {
             $s_type .= "PlainTemplate ";
             $s_template = GetAROption("PlainTemplate");
             if (!ProcessTemplate($s_template, $a_lines, $a_values, GetAROption('TemplateMissing'), 'SubstituteValuePlain')) {
                 return false;
             }
             FMDebug("AutoRespond: PlainTemplate " . count($a_lines) . " lines");
             $s_mail_text = implode(Settings::get('BODY_LF'), $a_lines);
         }
         if (IsAROptionSet("HTMLTemplate")) {
             $s_type .= "HTMLTemplate ";
             if (!MakeMimeMail($s_mail_text, $a_headers, $a_values, GetAROption("HTMLTemplate"), GetAROption('TemplateMissing'))) {
                 return false;
             }
             FMDebug("AutoRespond: HTMLTemplate " . strlen($s_mail_text) . " bytes");
         }
     } else {
         if (IsAROptionSet('PlainFile')) {
             $s_type .= "PlainFile ";
             //
             // load the plain text file from the templates area
             //
             if (Settings::isEmpty('TEMPLATEDIR') && Settings::isEmpty('TEMPLATEURL')) {
                 SendAlert(GetMessage(MSG_TEMPLATES));
                 return false;
             }
             $s_file = GetAROption("PlainFile");
             if (($a_lines = LoadTemplate($s_file, Settings::get('TEMPLATEDIR'), Settings::get('TEMPLATEURL'), true)) === false) {
                 return false;
             }
             $s_mail_text = implode(Settings::get('BODY_LF'), $a_lines);
             FMDebug("AutoRespond: PlainFile " . count($a_lines) . " lines");
         }
         if (IsAROptionSet("HTMLFile")) {
             $s_type .= "HTMLFile ";
             if (!MakeMimeMail($s_mail_text, $a_headers, $a_values, GetAROption("HTMLFile"), "", false, "", array(), array(), false)) {
                 return false;
             }
             FMDebug("AutoRespond: HTMLTemplate " . strlen($s_mail_text) . " bytes");
         }
     }
     if (strlen($s_mail_text) == 0) {
         SendAlert(GetMessage(MSG_ARESP_EMPTY), array("TYPE" => $s_type));
     }
     FMDebug("AutoRespond: message is " . strlen($s_mail_text) . " bytes");
     return SendCheckedMail($s_to, $s_subj, $s_mail_text, $s_from_addr, $a_headers);
 }
 function _SendEmail($s_to, $s_subj, $a_values, $b_use_template)
 {
     global $aPHPVERSION, $SPECIAL_VALUES, $FROM_USER;
     //
     // need PHP 4.0.5 for the preg_replace_callback function
     //
     if (!IsPHPAtLeast("4.0.5")) {
         SendAlert(GetMessage(MSG_PHP_AUTORESP, array("PHPVERS" => implode(".", $aPHPVERSION))));
         return false;
     }
     $a_headers = array();
     $s_mail_text = "";
     $s_from_addr = GetAROption("FromAddr");
     if (!isset($s_from_addr)) {
         $s_from_addr = "";
         if (isset($FROM_USER) && !empty($FROM_USER)) {
             if ($FROM_USER != "NONE") {
                 $s_from_addr = $FROM_USER;
             }
         } else {
             global $SERVER;
             $s_from_addr = "FormMail@" . $SERVER;
         }
     } else {
         $s_from_addr = UnMangle($s_from_addr);
     }
     if (!empty($s_from_addr)) {
         $a_headers['From'] = SafeHeader($s_from_addr);
     }
     $s_type = "";
     if ($b_use_template) {
         if (IsAROptionSet('PlainTemplate')) {
             $s_type .= "PlainTemplate ";
             $s_template = GetAROption("PlainTemplate");
             if (!ProcessTemplate($s_template, $a_lines, $a_values, GetAROption('TemplateMissing'), 'SubstituteValuePlain')) {
                 return false;
             }
             FMDebug("AutoRespond: PlainTemplate " . count($a_lines) . " lines");
             $s_mail_text = implode(BODY_LF, $a_lines);
         }
         if (IsAROptionSet("HTMLTemplate")) {
             $s_type .= "HTMLTemplate ";
             if (!MakeMimeMail($s_mail_text, $a_headers, $a_values, GetAROption("HTMLTemplate"), GetAROption('TemplateMissing'))) {
                 return false;
             }
             FMDebug("AutoRespond: HTMLTemplate " . strlen($s_mail_text) . " bytes");
         }
     } else {
         global $TEMPLATEURL, $TEMPLATEDIR;
         if (IsAROptionSet('PlainFile')) {
             $s_type .= "PlainFile ";
             //
             // load the plain text file from the templates area
             //
             if (empty($TEMPLATEDIR) && empty($TEMPLATEURL)) {
                 SendAlert(GetMessage(MSG_TEMPLATES));
                 return false;
             }
             $s_file = GetAROption("PlainFile");
             if (($a_lines = LoadTemplate($s_file, $TEMPLATEDIR, $TEMPLATEURL, true)) === false) {
                 return false;
             }
             $s_mail_text = implode(BODY_LF, $a_lines);
             FMDebug("AutoRespond: PlainFile " . count($a_lines) . " lines");
         }
         if (IsAROptionSet("HTMLFile")) {
             $s_type .= "HTMLFile ";
             if (!MakeMimeMail($s_mail_text, $a_headers, $a_values, GetAROption("HTMLFile"), "", false, "", array(), array(), false)) {
                 return false;
             }
             FMDebug("AutoRespond: HTMLTemplate " . strlen($s_mail_text) . " bytes");
         }
     }
     if (strlen($s_mail_text) == 0) {
         SendAlert(GetMessage(MSG_ARESP_EMPTY), array("TYPE" => $s_type));
     }
     FMDebug("AutoRespond: message is " . strlen($s_mail_text) . " bytes");
     return SendCheckedMail($s_to, $s_subj, $s_mail_text, $s_from_addr, $a_headers);
 }
Exemplo n.º 3
0
function AutoRespond($s_to, $s_subj, $a_values)
{
    global $aPHPVERSION, $SPECIAL_VALUES, $FROM_USER;
    //
    // need PHP 4.0.5 for the preg_replace_callback function
    //
    if (!IsPHPAtLeast("4.0.5")) {
        SendAlert(GetMessage(MSG_PHP_AUTORESP, array("PHPVERS" => implode(".", $aPHPVERSION))));
        return false;
    }
    $a_headers = array();
    $s_mail_text = "";
    $s_from_addr = "";
    if (isset($FROM_USER) && !empty($FROM_USER)) {
        if ($FROM_USER != "NONE") {
            $s_from_addr = $a_headers['From'] = $FROM_USER;
        }
    } else {
        global $SERVER;
        $s_from_addr = "FormMail@" . $SERVER;
        $a_headers['From'] = $s_from_addr;
    }
    if (IsAROptionSet('PlainTemplate')) {
        $s_template = GetAROption("PlainTemplate");
        if (!ProcessTemplate($s_template, $a_lines, $a_values, GetAROption('TemplateMissing'), 'SubstituteValuePlain')) {
            return false;
        }
        $s_mail_text = implode(BODY_LF, $a_lines);
    }
    if (IsAROptionSet("HTMLTemplate")) {
        if (!MakeMimeMail($s_mail_text, $a_headers, $a_values, GetAROption("HTMLTemplate"), GetAROption('TemplateMissing'))) {
            return false;
        }
    }
    return SendCheckedMail($s_to, $s_subj, $s_mail_text, $s_from_addr, $a_headers);
}