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 = '';
    #  print "Sending $to from $fromemail<br/>";
    if (DEVVERSION) {
        $message = "To: {$to}\n" . $message;
        if ($GLOBALS['developer_email']) {
            $destinationemail = $GLOBALS['developer_email'];
        } else {
            print 'Error: Running DEV version, but developer_email not set';
        }
    } else {
        $destinationemail = $to;
    }
    list($htmlmessage, $textmessage) = constructSystemMail($message, $subject);
    $mail = new PHPlistMailer('systemmessage', $destinationemail, false);
    if (!empty($htmlmessage)) {
        $mail->add_html($htmlmessage, $textmessage, getConfig('systemmessagetemplate'));
        ## In the above phpMailer strips all tags, which removes the links which are wrapped in < and > by HTML2text
        ## so add it again
        $mail->add_text($textmessage);
    }
    $mail->add_text($textmessage);
    # 0008549: message envelope not passed to php mailer,
    $mail->Sender = $GLOBALS['message_envelope'];
    ## always add the List-Unsubscribe header
    $removeurl = getConfig('unsubscribeurl');
    $sep = strpos($removeurl, '?') === false ? '?' : '&';
    $mail->addCustomHeader('List-Unsubscribe: <' . $removeurl . $sep . 'email=' . $to . '&jo=1>');
    return $mail->compatSend('', $destinationemail, $fromname, $fromemail, $subject);
}