From 4da9410f9030b63bd24f664aadfac1e7dfe568a3 Mon Sep 17 00:00:00 2001 From: Christian Steinle Date: Sat, 10 Dec 2016 10:10:52 +0000 Subject: [PATCH] Umbau EMail-Versand auf phpMailer Bereinigung alte Revisionierung TCPDF --- inc/config.php | 3 +-- inhalte/mail.php | 64 ++++++++++++------------------------------------ 2 files changed, 17 insertions(+), 50 deletions(-) diff --git a/inc/config.php b/inc/config.php index 45f2040..4288341 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1,6 +1,5 @@ "; -$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("

Die Nachricht konnte nicht versendet werden. Bitte gehen Sie zurück und versuchen Sie es noch einmal!

"); } else { echo "

Die Email wurde erfolgreich versendet.

\n"; -} \ No newline at end of file +}