| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?php
- //declare(strict_types=1);
- # Autoload
- use PHPMailer\PHPMailer\PHPMailer;
- use PHPMailer\PHPMailer\SMTP;
- use PHPMailer\PHPMailer\Exception;
- use Skrepr\TeamsConnector\Card;
- use Skrepr\TeamsConnector\CardInterface;
- use Skrepr\TeamsConnector\Client;
- require __DIR__ . '/../vendor/autoload.php';
- function url(){
- return sprintf(
- "%s://%s",
- isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' ? 'https' : 'http',
- $_SERVER['SERVER_NAME']
- );
- }
- if($_POST) {
- $name = trim(stripslashes($_POST['name']));
- $email = trim(stripslashes($_POST['email']));
- $subject = trim(stripslashes($_POST['subject']));
- $computer = strtoupper(trim(stripslashes($_POST['computer'])));
- $phone = trim(stripslashes($_POST['phone']));
- $location = trim(stripslashes($_POST['location']));
- // $file = trim(stripslashes($_POST['datei']));
- $contact_message = trim(stripslashes($_POST['message']));
- if ($subject == '') { $subject = "Supportanfrage"; }
- // Set Message
- $message = "<h2>Supportanfrage:</h2><br/>";
- $message .= "<b>Vor- / Nachname:</b> " . $name . "<br />";
- $message .= "<b>Email:</b> " . $email . "<br />";
- $message .= "<b>Telefon:</b> " . $phone . "<br />";
- $message .= "<b>Standort:</b> " . $location . "<br />";
- $message .= "<b>Computer:</b> " . $computer . "<br />";
- $message .= "<b>Betreff:</b> " . $subject . "<br />";
- $message .= "<br/><b>Nachricht:</b><br />";
- $message .= "<hr>";
- // $message .= "<a src='".$file."'></a>";
- // $message .= "<hr>";
- $message .= nl2br($contact_message);
- $message .= "<hr>";
- $message .= "<br/><br/><i>Diese Nachricht kam über das Support Formular</i><br />";
- // Daten lokal ablegen:
- $filename = date("YmdHis") . "_" . $computer . '.json';
- file_put_contents("../auftraege/".$filename, json_encode($message, JSON_UNESCAPED_UNICODE), FILE_APPEND | LOCK_EX);
- include __DIR__."/addticket.php";
- if ( $ticket->statuscode == 201 ) {
- # Anlage per API erfolgreich!
- }
- else {
- # Send eMail
- try {
- // Versuch, eine neue Instanz der Klasse PHPMailer zu erstellen
- $mail = new PHPMailer (true);
- //$mail->SMTPDebug = SMTP::DEBUG_SERVER;
- $mail->isSMTP();
- $mail->Host = "postfix";
- $mail->Port = "25";
- $mail->SMTPAuth = false;
- $mail->CharSet = 'UTF-8';
- $mail->Encoding = 'base64';
- if ($computer==="TEST") {
- $mail->setFrom('vadmin@xtend.de', 'Vadmin Xtend');
- } else {
- $mail->setFrom('dialog-it@xtend.de', 'dialog-it Xtend');
- }
- $mail->addAddress('rmm@vision4it.de', 'Empfänger');
- //$mail->addAddress('as@vision4it.de', 'Empfänger');
- $mail->isHTML(true);
- $mail->Subject = $subject;
- $mail->Body = $message;
- $mail->send();
- echo "OK";
- } catch (Exception $e) {
- echo "<h2>Fehler beim Senden der eMail...</h2>";
- }
- }
-
- # Send to MS Teams Channel:
- try {
- if ($computer==="TEST") {
- $endPoint = 'https://vision4itmanufaktur.webhook.office.com/webhookb2/6015fd18-7016-4c5c-9a8b-322f544e23a1@b21d8bf4-1752-4aee-8c45-fdfeea4f5fc2/IncomingWebhook/715dcdf468624502943c33b76da814bc/c17f1d0d-51e3-4149-b1e4-7caa4a45867f';
- } else {
- $endPoint = 'https://xtend975.webhook.office.com/webhookb2/17865e5c-cdd2-48e4-bf53-4ced058490cf@9a94220a-3366-479f-ad5f-2157f19d9307/IncomingWebhook/6f60fe6837ff47739821154863f8a9a3/da7b9b09-3ffa-4280-bd0c-ae79e01f813f';
- }
- $httpClient = new \GuzzleHttp\Client();
- $teamsClient = new Client($endPoint, $httpClient);
- $card = (new Card('Supportanfrage'))
- ->setText($message)
- ->setThemeColor(CardInterface::STATUS_DEFAULT)
- ->setTitle('Problem: '.$subject);
- $teamsClient->send($card);
- } catch (Exception $e) {
- echo "<h2>Fehler beim Senden an MS Teams Channel...</h2>";
- }
- }
- ?>
|