Umbau EMail-Versand auf phpMailer

Bereinigung alte Revisionierung TCPDF
This commit is contained in:
2016-12-10 10:10:52 +00:00
parent 689519e6cb
commit 4da9410f90
2 changed files with 17 additions and 50 deletions

View File

@@ -1,6 +1,5 @@
<?php
//include "funktionen.php";
include "variablen.php";
include "konstanten.php";
include __DIR__ . "/../config/content_de.php";
require_once(__DIR__ . '/tcpdf/tcpdf.php');

View File

@@ -1,57 +1,25 @@
<?php
$fileatt = $_POST['Attached'];
$fileatt_name = $_POST['ID'];
$email_from = $_POST['Name_from'] . " <" . $_POST['Email_from'] . ">";
$email_subject = $_POST['Subject'];
$email_message = $_POST['Text'];
//$email_message =
$email_to = $_POST['Email_to'];
$phpMailer = new PHPMailer();
$phpMailer->From = $_POST['Email_from'];
$phpMailer->FromName = $_POST['Name_from'];
$phpMailer->CharSet = 'UTF-8';
$phpMailer->isSendmail();
$phpMailer->addReplyTo($_POST['Email_from']);
$phpMailer->addAddress($_POST['Email_to']);
$phpMailer->addBCC($_POST['Email_from']);
$phpMailer->isHtml(false);
$phpMailer->Subject = $email_subject;
$phpMailer->Body = $_POST['Text'];
$phpMailer->addAttachment($_POST['Attached']);
$phpMailer->send();
$fileatt_type = "application/octet-stream"; // File Type
$headers = "From: " . $email_from . "\n";
$headers .= "Reply-To: " . $email_from . "\n";
if ("1" == $_SESSION['Firma']['Email_Kopie'])
{
$headers .= "BCC: <" . $_SESSION['Firma']['Email'] . ">";
}
$file = fopen($fileatt, 'rb');
$data = fread($file, filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$email_message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type:text; charset=\"utf-8\"\n" .
"Content-Transfer-Encoding: 8bit\n\n" .
$email_message . "\n\n";
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
$ok = @mail($email_to, $email_subject, $email_message, $headers);
if (!$ok)
$ok = $phpMailer->ErrorInfo;
if ($ok !== '')
{
die("<h1>Die Nachricht konnte nicht versendet werden. Bitte gehen Sie zurück und versuchen Sie es noch einmal!</h1>");
}
else
{
echo "<h1>Die Email wurde erfolgreich versendet.</h1>\n";
}
}