Beispiel #1
0
function sendMailPhpMailer($to, $subject, $message)
{
    # global function to capture sending emails, to avoid trouble with
    # older (and newer!) php versions
    $fromemail = getConfig("message_from_address");
    $fromname = getConfig("message_from_name");
    $message_replyto_address = getConfig("message_replyto_address");
    if ($message_replyto_address) {
        $reply_to = $message_replyto_address;
    } else {
        $reply_to = $from_address;
    }
    $destinationemail = '';
    if (!ereg("dev", VERSION)) {
        $mail = new PHPlistMailer('systemmessage', $to);
        $destinationemail = $to;
        $mail->add_text($message);
    } else {
        # send mails to one place when running a test version
        $message = "To: {$to}\n" . $message;
        if ($GLOBALS["developer_email"]) {
            # fake occasional failure
            if (mt_rand(0, 50) == 1) {
                return 0;
            } else {
                $mail = new PHPlistMailer('systemmessage', $GLOBALS["developer_email"]);
                $mail->add_text($message);
                $destinationemail = $GLOBALS["developer_email"];
            }
        } else {
            print "Error: Running CVS version, but developer_email not set";
        }
    }
    # 0008549: message envelope not passed to php mailer,
    $mail->Sender = $GLOBALS["message_envelope"];
    $mail->build_message(array("html_charset" => getConfig("html_charset"), "html_encoding" => HTMLEMAIL_ENCODING, "text_charset" => getConfig("text_charset"), "text_encoding" => TEXTEMAIL_ENCODING));
    return $mail->send("", $destinationemail, $fromname, $fromemail, $subject);
}