Example #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;
    }
}
Example #2
0
function sent_mail($to, $fromname, $fromemail, $subject, $body, $multiple = false, $multiplemail = '')
{
    global $SITENAME, $SITEEMAIL, $smtptype, $smtp, $smtp_host, $smtp_port, $smtp_from, $smtpaddress, $accountname, $accountpassword, $rootpath;
    # Sent Mail Function v.05 by xam (This function to help avoid spam-filters.)
    $result = true;
    if ($smtptype == 'default') {
        @mail($to, $subject, $body, "From: {$SITEEMAIL}") or $result = false;
    } elseif ($smtptype == 'advanced') {
        # 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";
        }
        $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/plain; charset=windows-1251" . $eol;
        $headers .= "X-Sender: PHP" . $eol;
        if ($multiple) {
            $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, $subject, $body, $headers) or $result = false;
        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();
        $mail->debug(false);
        $mail->open($smtp_host, $smtp_port);
        if (!empty($accountname) && !empty($accountpassword)) {
            $mail->auth($accountname, $accountpassword);
        }
        $mail->from($SITEEMAIL);
        $mail->to($to);
        $mail->subject($subject);
        $mail->body($body);
        $result = $mail->send();
        $mail->close();
    } else {
        $result = false;
    }
    return $result;
}