Пример #1
0
function sent_mail($to, $fromname, $fromemail, $subject, $body, $type = "confirmation", $showmsg = true, $multiple = false, $multiplemail = '', $hdr_encoding = 'UTF-8', $specialcase = '')
{
    global $lang_functions;
    global $rootpath, $SITENAME, $SITEEMAIL, $smtptype, $smtp, $smtp_host, $smtp_port, $smtp_from, $smtpaddress, $smtpport, $accountname, $accountpassword;
    # Is the OS Windows or Mac or Linux?
    if (strtoupper(substr(PHP_OS, 0, 3) == 'WIN')) {
        $eol = "\r\n";
        $windows = true;
    } elseif (strtoupper(substr(PHP_OS, 0, 3) == 'MAC')) {
        $eol = "\r";
    } else {
        $eol = "\n";
    }
    if ($smtptype == 'none') {
        return false;
    }
    if ($smtptype == 'default') {
        @mail($to, "=?" . $hdr_encoding . "?B?" . base64_encode($subject) . "?=", $body, "From: " . $SITEEMAIL . $eol . "Content-type: text/html; charset=" . $hdr_encoding . $eol, "-f{$SITEEMAIL}") or stderr($lang_functions['std_error'], $lang_functions['text_unable_to_send_mail']);
    } elseif ($smtptype == 'advanced') {
        $mid = md5(getip() . $fromname);
        $name = $_SERVER["SERVER_NAME"];
        $headers .= "From: {$fromname} <{$fromemail}>" . $eol;
        $headers .= "Reply-To: {$fromname} <{$fromemail}>" . $eol;
        $headers .= "Return-Path: {$fromname} <{$fromemail}>" . $eol;
        $headers .= "Message-ID: <{$mid} thesystem@{$name}>" . $eol;
        $headers .= "X-Mailer: PHP v" . phpversion() . $eol;
        $headers .= "MIME-Version: 1.0" . $eol;
        $headers .= "Content-type: text/html; charset=" . $hdr_encoding . $eol;
        $headers .= "X-Sender: PHP" . $eol;
        if ($multiple) {
            $bcc_multiplemail = "";
            foreach ($multiplemail as $toemail) {
                $bcc_multiplemail = $bcc_multiplemail . ($bcc_multiplemail != "" ? "," : "") . $toemail;
            }
            $headers .= "Bcc: {$multiplemail}.{$eol}";
        }
        if ($smtp == "yes") {
            ini_set('SMTP', $smtp_host);
            ini_set('smtp_port', $smtp_port);
            if ($windows) {
                ini_set('sendmail_from', $smtp_from);
            }
        }
        @mail($to, "=?" . $hdr_encoding . "?B?" . base64_encode($subject) . "?=", $body, $headers) or stderr($lang_functions['std_error'], $lang_functions['text_unable_to_send_mail']);
        ini_restore(SMTP);
        ini_restore(smtp_port);
        if ($windows) {
            ini_restore(sendmail_from);
        }
    } elseif ($smtptype == 'external') {
        require_once $rootpath . 'include/smtp/smtp.lib.php';
        $mail = new smtp($hdr_encoding, 'eYou');
        $mail->debug(false);
        $mail->open($smtpaddress, $smtpport);
        $mail->auth($accountname, $accountpassword);
        //	$mail->bcc($multiplemail);
        $mail->from($SITEEMAIL);
        if ($multiple) {
            $mail->multi_to_head($to);
            foreach ($multiplemail as $toemail) {
                $mail->multi_to($toemail);
            }
        } else {
            $mail->to($to);
        }
        $mail->mime_content_transfer_encoding();
        $mail->mime_charset('text/html', $hdr_encoding);
        $mail->subject($subject);
        $mail->body($body);
        $mail->send() or stderr($lang_functions['std_error'], $lang_functions['text_unable_to_send_mail']);
        $mail->close();
    }
    if ($showmsg) {
        if ($type == "confirmation") {
            stderr($lang_functions['std_success'], $lang_functions['std_confirmation_email_sent'] . "<b>" . htmlspecialchars($to) . "</b>.\n" . $lang_functions['std_please_wait'], false);
        } elseif ($type == "details") {
            stderr($lang_functions['std_success'], $lang_functions['std_account_details_sent'] . "<b>" . htmlspecialchars($to) . "</b>.\n" . $lang_functions['std_please_wait'], false);
        }
    } else {
        return true;
    }
}