70 lines
2.2 KiB
PHP
70 lines
2.2 KiB
PHP
<?php
|
|
require_once 'log.php';
|
|
require_once 'fonctions.inc.php';
|
|
|
|
|
|
function courrielEnvoi( $db )
|
|
{
|
|
$dicoExpe = getLang( $db->expeLang );
|
|
$dicoDest = getLang( $db->destLang );
|
|
$expediteurIndex = "Notification_denvoi_Expediteur";
|
|
//print "envoi du courriel" . EOL;
|
|
|
|
// Message à l'expéditeur
|
|
$indexObjet = "Objet_" . $expediteurIndex;
|
|
$objetMail = replaceVariables($db, $dicoExpe[$indexObjet], $dicoExpe);
|
|
$mailText = replaceVariables($db, $dicoExpe[$expediteurIndex], $dicoExpe) .EOL .EOL ;
|
|
if ( $db->expeKnown == false )
|
|
{
|
|
$destinataireIndex = "Notification_denvoi_Destinataire_ExpediteurConnu";
|
|
}else
|
|
{
|
|
$destinataireIndex = "Notification_denvoi_Destinataire_ExpediteurAnonyme";
|
|
}
|
|
|
|
saveMail( $db, $db->expeMail, $objetMail, $mailText);
|
|
|
|
// message au destinataire
|
|
$indexObjet = "Objet_" . $destinataireIndex;
|
|
$objetMail = replaceVariables($db, $dicoExpe[$indexObjet], $dicoDest);
|
|
$mailText = replaceVariables($db, $dicoDest[$destinataireIndex], $dicoDest) .EOL .EOL ;
|
|
|
|
saveMail( $db, $db->destMail, $objetMail, $mailText);
|
|
}
|
|
|
|
function saveMail( $db, $destinataire, $objet, $text, $html=FALSE)
|
|
{
|
|
$query = "INSERT INTO courriels VALUES ('0', '" . $db->protect($destinataire) . "', '" . $db->protect($objet) . "', '" . $db->protect($text) . "', '" . (int)$html . "')";
|
|
$db->query($query);
|
|
}
|
|
|
|
function envoiMail($destinataire, $sujet, $text, $html=false, $cc='', $bcc='')
|
|
{
|
|
$headers = "From: contact@avion-poe.me" . LF;
|
|
if ( !empty($cc)) $headers .= "Cc: " . $cc . LF;
|
|
if ( !empty($bcc)) $headers .= "Bcc: " . $bcc . LF;
|
|
|
|
if (empty($html))
|
|
{
|
|
$headers .= "Content-type: text/plain; charset=UTF-8" . LF;
|
|
}else
|
|
{
|
|
$headers .= "Content-type: text/html; charset=UTF-8" . LF;
|
|
nl2br($text);
|
|
}
|
|
$headers .= "DATE: " . date( 'r' ) . LF . LF;
|
|
|
|
log_write(__FILE__ . __LINE__ . " Envoi d'un courriel à " . $destinataire . "sujet:" . $sujet, INFO);
|
|
if( !mail($destinataire, $sujet, wordwrap($text, 70 , "\r\n"), $headers) ) //Sending mail
|
|
{
|
|
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel n'est pas parti:" .$destinataire . EOL . $sujet, ERROR);
|
|
return false;
|
|
}else
|
|
{
|
|
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel est parti: " . $destinataire . EOL . "text:" . $text, INFO);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
?>
|