Beispiel #1
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;
         }
     }
 }