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);
}
Beispiel #2
0
function sendMailDirect($destinationemail, $subject, $message)
{
    $GLOBALS['smtpError'] = '';
    ## try to deliver directly, so that any error (eg user not found) can be sent back to the
    ## subscriber, so they can fix it
    unset($GLOBALS['developer_email']);
    list($htmlmessage, $textmessage) = constructSystemMail($message, $subject);
    $mail = new PHPlistMailer('systemmessage', $destinationemail, false, true);
    list($dummy, $domain) = explode('@', $destinationemail);
    #print_r ($mxhosts);exit;
    $smtpServer = getTopSmtpServer($domain);
    $fromemail = getConfig('message_from_address');
    $fromname = getConfig('message_from_name');
    $mail->Host = $smtpServer;
    $mail->Helo = getConfig('website');
    $mail->Port = 25;
    $mail->Mailer = 'smtp';
    if (!empty($htmlmessage)) {
        $mail->add_html($htmlmessage, $textmessage, getConfig('systemmessagetemplate'));
        $mail->add_text($textmessage);
    }
    $mail->add_text($textmessage);
    try {
        $mail->Send('', $destinationemail, $fromname, $fromemail, $subject);
    } catch (Exception $e) {
        $GLOBALS['smtpError'] = $e->getMessage();
        return false;
    }
    return true;
}