Skip to content
Snippets Groups Projects
Commit 440b7bc7 authored by Florian Azizian's avatar Florian Azizian
Browse files

FEAT #5972 Send notif when sendmail is not working

parent f0dd6894
No related branches found
No related tags found
No related merge requests found
......@@ -46,6 +46,10 @@
<x-mailer></x-mailer><!-- Rewrite X-Mailer header, default : PHP/[phpversion] -->
<mailfrom></mailfrom> <!-- if not empty we use this address to send the mail -->
</MAILER>
<NOTIFICATION_ERROR>
<adminmail>dev@maarch.org</adminmail><!--separate with a coma if multiple recipient-->
<subjectmail>[Maarch Courrier] Problème avec l'envoi de courriel</subjectmail>
</NOTIFICATION_ERROR>
<LOG4PHP>
<enabled>true</enabled>
<Log4PhpLogger>loggerTechnique</Log4PhpLogger>
......
......@@ -148,6 +148,10 @@ $GLOBALS['batchDirectory'] = $GLOBALS['maarchDirectory'] . 'modules'
. DIRECTORY_SEPARATOR . 'sendmail'
. DIRECTORY_SEPARATOR . 'batch';
$notificationErrors = $xmlconfig->NOTIFICATION_ERROR;
$GLOBALS['adminmail'] = (string)$notificationErrors->adminmail;
$GLOBALS['subjectmail'] = (string)$notificationErrors->subjectmail;
set_include_path(get_include_path() . PATH_SEPARATOR . $GLOBALS['maarchDirectory']);
//log4php params
......
......@@ -67,7 +67,7 @@ while ($state <> 'END') {
$GLOBALS['mailer']->setFrom($userInfo['firstname'].' '
. $userInfo['lastname'].' <'.$mailfrom_generic.'> ');
$emailFrom = $mailfrom_generic;
$email->email_body = 'Courriel envoyé par : ' . $userInfo['firstname'].' '
. $userInfo['lastname'] . ' ' . $email->sender_email . ' ' . '.<br/><br/>' . $email->email_body;
} else {
......@@ -76,6 +76,7 @@ while ($state <> 'END') {
$GLOBALS['mailer']->setFrom($userInfo['firstname'].' '
. $userInfo['lastname'].' <'.$email->sender_email.'> ');
$emailFrom = $email->sender_email;
}
$GLOBALS['mailer']->setReplyTo($email->sender_email);
......@@ -85,12 +86,14 @@ while ($state <> 'END') {
$entityShortLabel = substr($mailsEntities[$email->sender_email], 0, strrpos($mailsEntities[$email->sender_email], "("));
$GLOBALS['mailer']->setFrom($entityShortLabel . ' <' . $mailfrom_generic. '> ');
$emailFrom = $mailfrom_generic;
$email->email_body = 'Courriel envoyé par : ' . $entityShortLabel . ' ' . $sendmail_tools->explodeSenderEmail($email->sender_email) . ' ' . '.<br/><br/>' . $email->email_body;
} else {
$mailsEntities = $sendmail_tools->getAttachedEntitiesMails();
$entityShortLabel = substr($mailsEntities[$email->sender_email], 0, strrpos($mailsEntities[$email->sender_email], "("));
$GLOBALS['mailer']->setFrom($entityShortLabel . ' <' . $sendmail_tools->explodeSenderEmail($email->sender_email) . '> ');
$emailFrom = $sendmail_tools->explodeSenderEmail($email->sender_email);
}
$GLOBALS['mailer']->setReplyTo($sendmail_tools->explodeSenderEmail($email->sender_email));
}
......@@ -255,6 +258,26 @@ while ($state <> 'END') {
$exec_result = 'E';
$err++;
$errTxt = ' (Last Error : '.$return[0].')';
$query = "INSERT INTO notif_email_stack (sender, recipient, subject, html_body, charset, module) VALUES (?, ?, ?, ?, ?, 'notifications')";
$html = "Message automatique : <br><br>
L'email avec l'identifiant ".$email->email_id." dans la table 'sendmail' n'a pas été envoyé. <br>
Pour plus d'informations, regardez les logs dans le fichier ".$GLOBALS['maarchDirectory']."/modules/sendmail/batch/".$logFile."<br><br>
Répertoire d'installation de l'application : ".$GLOBALS['maarchDirectory']."<br>
Fichier de configuration de sendmail : " . $GLOBALS['configFile'] . "<br>
IP de la base de données : " . $_SESSION['config']['databaseserver'] . "<br>
Port de la base de données : " . $_SESSION['config']['databaseserverport'] . "<br>
Type de base de données : " . $_SESSION['config']['databasetype'] . "<br>
Nom de la base de données : " . $_SESSION['config']['databasename'] . "<br>";
$adminMails = explode(',', $GLOBALS['adminmail']);
foreach($adminMails as $recipient){
if(!empty($recipient)){
Bt_doQuery($GLOBALS['db'], $query, array($emailFrom, $recipient, $GLOBALS['subjectmail'], $html, $GLOBALS['charset']));
}
}
}
//Update emails table
$query = "UPDATE " . EMAILS_TABLE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment