/**
  * Envoie de mail sur l'evolution des données de la transactions depuis Arcadia
  * @param string $paramSujet
  * @param string $paramCorpMail
  * @param string $paramArdTto
  * @param string $paramArdFrom
  * @param string $paramUrlSmtp
  * @return string
  */
 function sendMail($paramSujet, $paramCorpMail, $paramArdTto, $paramArdFrom, $paramUrlSmtp)
 {
     //Création du mail
     $mail = new htmlMimeMail5();
     //
     $mail->setSMTPParams($paramUrlSmtp);
     // Set the From and Reply-To headers
     $mail->setFrom($paramArdFrom);
     $mail->setReturnPath($paramArdFrom);
     // Set the Subject
     $mail->setSubject($paramSujet);
     /**
      * Encodement en utf-8
      */
     $mail->setTextCharset("UTF-8");
     $mail->setHTMLCharset("UTF-8");
     $mail->setHeadCharset("UTF-8");
     // Set the body
     $mail->setHTML(nl2br($paramCorpMail));
     /**
      * L'envoi réel du mail n'est pas réalisé en environnement Codeur
      */
     $result = $mail->send(array($paramArdTto), 'smtp');
     return $result;
 }
Beispiel #2
0
 function send_report_mail($recipient)
 {
     global $PATH, $MAIL_CFG, $LNK;
     $fullfilename = $this->fname;
     $msg = "Ein Backup vom Server zum Backup-Server wurde erstellt. Dabei wurde folgendes Protokoll erstellt:\n\n";
     $msg .= $fullfilename . "\n\n";
     $msg .= "Es gab folgende FEHLER (nur solche, die automatisch erfasst werden konnten):\n\n";
     $sql = "select * from reports where klasse like 'ERROR' order by uid asc;";
     $result = mysqli_query($LNK, $sql);
     $txt = "";
     while ($row = mysqli_fetch_assoc($result)) {
         $txt .= $row["datum"] . "\t";
         $txt .= $row["meldung"] . "\n";
     }
     $msg .= $txt;
     if ($txt == "") {
         $msg .= "< KEINE. >";
     }
     $msg .= "\n\n\nEs gab folgende WARNUNGEN:\n\n";
     $sql = "select * from reports where klasse like 'WARNING' order by uid asc;";
     $result = mysqli_query($LNK, $sql);
     $txt = "";
     while ($row = mysqli_fetch_assoc($result)) {
         $txt .= $row["datum"] . "\t";
         $txt .= $row["meldung"] . "\n";
     }
     $msg .= $txt;
     if ($txt == "") {
         $msg .= "< KEINE. >";
     }
     $mail = new htmlMimeMail5();
     $mail->setFrom($MAIL_CFG["from"]);
     $mail->setSubject('Backup-Durchlauf ' . strftime('%d.%m.%y %H:%M:%S', time()));
     $mail->setHeader('Date', date('D, d M y H:i:s O'));
     $mail->setTextCharset('UTF-8');
     $mail->setText($msg);
     $mail->setHtmlCharset('UTF-8');
     $mail->setHTML(file_get_contents($this->fname));
     // $mail->addEmbeddedImage(new fileEmbeddedImage($PATH."img/APPrototype.gif"));
     // $mail->addAttachment(new fileAttachment('example.zip'));
     $mail->setSMTPParams($MAIL_CFG["host"], $MAIL_CFG["port"], $MAIL_CFG["helo"], $MAIL_CFG["auth"], $MAIL_CFG["user"], $MAIL_CFG["pass"]);
     $mail->send(array($recipient), 'smtp');
     // first param is an array!
     if (isset($mail->errors)) {
         echo "\n\n\nFehler beim Versand der Report-Mail an {$recipient} !\n\n\n";
         if (is_array($mail->errors)) {
             echo implode("; ", $mail->errors) . "\n";
             // non-fatal;
         } else {
             errlog($mail->errors) . "\n";
             // non-fatal;
         }
     }
 }
function envoismail($sujetmail, $text, $destinataire, $expediteur, $paramTypeMail = null, $conf = null)
{
    if ($conf == null) {
        $globalConfig = new GlobalConfig();
    }
    if ($globalConfig->getConf()->getSmtpServiceEnable() == TRUE) {
        /*
         * Toutes les adresses emails sont redirigées vers utilisateurs.fta@ldc.fr
         * Si la redirection est mis en place
         */
        if ($globalConfig->getConf()->getSmtpEmailRedirectionUser()) {
            $destinataire_orig = $destinataire;
            $destinataire = $globalConfig->getConf()->getSmtpEmailRedirectionUser();
            $sujetmail_orig = $sujetmail;
            $sujetmail = "[Environnement " . $globalConfig->getConf()->getExecEnvironment() . "] " . $sujetmail_orig;
            $text_orig = $text;
            if (is_array($destinataire_orig)) {
                $listeDesDestinataire = explode(",", $destinataire_orig);
            } else {
                $listeDesDestinataire = $destinataire_orig;
            }
            $text = $listeDesDestinataire . "\n" . $text_orig;
        }
        //Création du mail
        $mail = new htmlMimeMail5();
        $mail->setSMTPParams($globalConfig->getConf()->getSmtpServerName());
        // Set the From and Reply-To headers
        $mail->setFrom($expediteur);
        $mail->setReturnPath($expediteur);
        // Set the Subject
        $mail->setSubject($sujetmail);
        /**
         * Encodement en utf-8
         */
        $mail->setTextCharset("UTF-8");
        $mail->setHTMLCharset("UTF-8");
        $mail->setHeadCharset("UTF-8");
        // Set the body
        $mail->setHTML(nl2br($text));
        //$result = $mail->send(array($adresse_to), 'smtp');
        //$result = $mail->send(array($destinataire), 'smtp');
        /**
         * L'envoi réel du mail n'est pas réalisé en environnement Codeur
         */
        if ($paramTypeMail != "mail-transactions") {
            $result = $mail->send(array($destinataire), 'smtp');
        }
        if (!$result and $globalConfig->getConf()->getExecEnvironment() == EnvironmentConf::ENV_PRD) {
            $paramTypeMail = "Erreur";
        }
    }
    /**
     * Génération de log
     */
    $paramLog = $paramTypeMail . " " . $expediteur . " " . $destinataire . "\n" . $sujetmail . "\n" . $text;
    //    Logger::AddMail($paramLog, $paramTypeMail);
}