fonctionnel sans mails en https
This commit is contained in:
@ -12,8 +12,17 @@ function courrielEnvoi( $db )
|
||||
|
||||
// Message à l'expéditeur
|
||||
$indexObjet = "Objet_" . $expediteurIndex;
|
||||
$objetMail = replaceVariables($db, $dicoExpe[$indexObjet], $dicoExpe);
|
||||
$mailText = replaceVariables($db, $dicoExpe[$expediteurIndex], $dicoExpe) .EOL .EOL ;
|
||||
$result = replaceVariables($db, $dicoExpe[$indexObjet], $dicoExpe);
|
||||
log_write("indexObjet" .EOLH . print_r($result, true));
|
||||
$objetMail = $result['text'];
|
||||
$result = replaceVariables($db, $dicoExpe[$expediteurIndex], $dicoExpe) ;
|
||||
log_write("indexObjet" .EOLH . print_r($result, true));
|
||||
$mailText = $result['text'];
|
||||
$html = $result['html'];
|
||||
if ( $html )
|
||||
{
|
||||
$mailText = "<html><head></head>\n<body>" . $mailText . "</body></html>";
|
||||
}
|
||||
if ( $db->expeKnown == false )
|
||||
{
|
||||
$destinataireIndex = "Notification_denvoi_Destinataire_ExpediteurConnu";
|
||||
@ -21,18 +30,25 @@ function courrielEnvoi( $db )
|
||||
{
|
||||
$destinataireIndex = "Notification_denvoi_Destinataire_ExpediteurAnonyme";
|
||||
}
|
||||
|
||||
saveMail( $db, $db->expeMail, $objetMail, $mailText);
|
||||
saveMail( $db, $db->expeMail, $objetMail, $mailText, $html);
|
||||
|
||||
// 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);
|
||||
$result = replaceVariables($db, $dicoDest[$indexObjet], $dicoDest);
|
||||
log_write("indexObjet" .EOLH . print_r($result, true));
|
||||
$objetMail = $result['text'];
|
||||
$result = replaceVariables($db, $dicoDest[$destinataireIndex], $dicoDest);
|
||||
log_write("indexObjet" .EOLH . print_r($result, true));
|
||||
$mailText = $result['text'];
|
||||
$html = $result['html'];
|
||||
if ( $html )
|
||||
{
|
||||
$message = "<html><head></head>\n<body>" . $message . "</body></html>";
|
||||
}
|
||||
saveMail( $db, $db->destMail, $objetMail, $mailText, $html);
|
||||
}
|
||||
|
||||
function saveMail( $db, $destinataire, $objet, $text, $html=FALSE)
|
||||
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);
|
||||
@ -44,20 +60,22 @@ function envoiMail($destinataire, $sujet, $text, $html=false, $cc='', $bcc='')
|
||||
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
|
||||
if ($html)
|
||||
{
|
||||
$headers .= "Content-type: text/html; charset=UTF-8" . LF;
|
||||
nl2br($text);
|
||||
}else
|
||||
{
|
||||
$headers .= "Content-type: text/plain; charset=UTF-8" . LF;
|
||||
$text = str_replace("\n","\r\n", $text);
|
||||
}
|
||||
$headers .= "DATE: " . date( 'r' ) . LF . LF;
|
||||
|
||||
$destinataire = "dtux@free.fr";
|
||||
log_write(__FILE__ . __LINE__ . " Envoi d'un courriel à " . $destinataire . "sujet:" . $sujet, INFO);
|
||||
if( !mail($destinataire, $sujet, wordwrap($text, 70 , "\r\n"), $headers) ) //Sending mail
|
||||
if( !mail($destinataire, $sujet, wordwrap($text, 1000 , "\r\n"), $headers) ) //Sending mail
|
||||
{
|
||||
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel n'est pas parti:" .$destinataire . EOL . $sujet, ERROR);
|
||||
$error = error_get_last();
|
||||
log_write(__FILE__ . EOL . __LINE__ . EOL . "Le courriel n'est pas parti:" .$destinataire . EOL . $sujet . EOL . print_r($error, true) . EOL . wordwrap($text, 1000 , "\r\n"), ERROR);
|
||||
return false;
|
||||
}else
|
||||
{
|
||||
|
Reference in New Issue
Block a user