Example #1
0
function CheckOutOfOffice($recipient, $from, $subject)
{
    $ldap = new clladp();
    $uid = $ldap->uid_from_email($recipient);
    if ($uid == null) {
        //events("unknown user $recipient from=<$from>",__FUNCTION__,__LINE__);
        $GLOBALS["uid"][$recipient] = "NO";
        return;
    } else {
        $GLOBALS["uid"][$recipient] = $uid;
    }
    $vacation = $ldap->UserVacation($uid);
    if ($vacation["vacationactive"][0] != "TRUE") {
        if ($GLOBALS["VERBOSE"]) {
            events("from=<{$from}>  <{$recipient}> (uid \"{$uid}\") ", __FUNCTION__, __LINE__);
            events("Vacation is disabled ({$vacation["vacationactive"][0]})", __FUNCTION__, __LINE__);
        }
        return;
    }
    $datefrom = $vacation["vacationstart"][0];
    $dateTo = $vacation["vacationend"][0];
    $DisplayName = $vacation["displayname"][0];
    $vacationinfo = stripslashes($vacation["vacationinfo"][0]);
    $now = time();
    if ($now < $datefrom) {
        events("Vacation not started {$datefrom}", __FUNCTION__, __LINE__);
        return;
    }
    if ($now >= $dateTo) {
        events("Vacation is finished {$dateTo}", __FUNCTION__, __LINE__);
        return;
    }
    $q = new mysql();
    $md5 = md5("{$datefrom}{$dateTo}{$from}{$uid}");
    $date = date('Y-m-d h:i:s');
    $sql = "SELECT zMD5 from OutOfOffice WHERE zMD5='{$md5}' LIMIT 0,1";
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, "artica_events"));
    if ($GLOBALS["VERBOSE"]) {
        events("zMD5={$ligne["zMD5"]} \"{$sql}\"", __FUNCTION__, __LINE__);
    }
    if ($ligne["zMD5"] != null) {
        events("Vacation is already sended", __FUNCTION__, __LINE__);
        return;
    }
    $mail = new simplemail();
    $mail->addrecipient($from, $from);
    $mail->addfrom($recipient, $DisplayName);
    $mail->addsubject("Re: {$subject}");
    $disctxt = br2nl($vacationinfo);
    $disctxt = p2nl($disctxt);
    $disctxt = strip_tags($disctxt);
    $disctxt = html_entity_decode($disctxt);
    $mail->text = $disctxt;
    $mail->html = $vacationinfo;
    if ($mail->sendmail()) {
        echo events("Auto-reply sent..", __FUNCTION__, __LINE__);
    } else {
        events("Auto-reply Error:{$mail->error_log}");
        return;
    }
    $sql = "INSERT INTO OutOfOffice (zMD5,uid,zDate,mailfrom) VALUES ('{$md5}','{$uid}',NOW(),'{$from}')";
    $q->QUERY_SQL($sql, "artica_events");
}
Example #2
0
<?php

// inclusion de la source de la classe
include 'class.mail.php';
// creation de l'instance
$mail = new simplemail();
//ajout du destinataire
$mail->addrecipient('*****@*****.**', 'tetsuo');
// ajout de l'expediteur
$mail->addfrom('*****@*****.**', 'gwbush');
//ajout du sujet
$mail->addsubject('yyy yyy');
// le message plaintext
$mail->text = 'plain text etc. etc. bla bla ...';
// envoie du message
if ($mail->sendmail()) {
    echo "envoyé";
} else {
    echo "erreur";
    echo $mail->error_log;
}