From fa52f3a34ee50db09e00aa4bbb1f3b85cb365911 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96sterreicher?= Date: Thu, 20 Sep 2018 18:31:32 +0200 Subject: [PATCH] =?UTF-8?q?Neue=20Mail=20Header=20hinzugef=C3=BCgt:=20Prec?= =?UTF-8?q?edence:=20bulk=20zur=20Markierung=20als=20Massenmail=20Auto-Sub?= =?UTF-8?q?mitted:=20auto-generated=20zur=20Markierung=20als=20automatisch?= =?UTF-8?q?=20generiertes=20E-Mail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/mail.class.php | 78 ++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/include/mail.class.php b/include/mail.class.php index b0285c11b..45f2fbc30 100644 --- a/include/mail.class.php +++ b/include/mail.class.php @@ -23,8 +23,8 @@ /** * Klasse Mail * @create 2008-11-20 - * - * Versendet ein Mail als Text, Html, CC und BCC Empfaenger, + * + * Versendet ein Mail als Text, Html, CC und BCC Empfaenger, * Replyto und Attachments */ @@ -40,7 +40,7 @@ class mail public $htmlContent; public $attachments; public $errormsg; - + /** * MAIL - Konstruktor * $to Empfaenger @@ -73,18 +73,18 @@ class mail $this->BCC_recievers = ($this->BCC_recievers!=''?MAIL_DEBUG:''); $this->replyTo = ($this->replyTo!=''?MAIL_DEBUG:''); } - + $mime_boundary_alternative = 'ALT+'.md5(time()); $mime_boundary_mixed = 'MIXD+'.md5(time()); $eol="\n"; - + if(defined('MAIL_FROM') && MAIL_FROM!='') $this->sender = MAIL_FROM; // Header $header = ''; $header .= "From: {$this->sender}".$eol; - + if (!empty($this->CC_recievers)) $header .= "CC: {$this->CC_recievers}".$eol; if (!empty($this->BCC_recievers)) @@ -94,11 +94,13 @@ class mail if (!empty($this->replyTo)) $header .= "Return-Path: {$this->replyTo}".$eol; - $header .= 'X-Mailer: FHComplete V1'.$eol; + $header .= 'X-Mailer: FHComplete V1'.$eol; $header .= 'Mime-Version: 1.0'.$eol; + $header .= 'Precedence: bulk'.$eol; + $header .= 'Auto-Submitted: auto-generated'.$eol; $header .= "Content-Type: multipart/related; boundary=\"$mime_boundary_mixed\"".$eol; $header .= "Content-Transfer-Encoding: 8bit".$eol; - + // Body $mailbody = ""; $mailbody .= $eol; @@ -112,8 +114,8 @@ class mail $mailbody .= $this->textContent[0]; $mailbody .= $eol; $mailbody .= $eol; - - if (!empty($this->htmlContent[0])) + + if (!empty($this->htmlContent[0])) { $mailbody .= "--$mime_boundary_alternative".$eol; $mailbody .= "Content-Type: text/html; charset={$this->htmlContent[1]}".$eol; @@ -126,17 +128,17 @@ class mail $mailbody .= "--{$mime_boundary_alternative}--".$eol; $mailbody .= $eol; $mailbody .= "--$mime_boundary_mixed"; - + // Attachments Plain - if (is_array($this->attachmentsplain) && (count($this->attachmentsplain) > 0)) + if (is_array($this->attachmentsplain) && (count($this->attachmentsplain) > 0)) { - foreach ($this->attachmentsplain as $attachment) + foreach ($this->attachmentsplain as $attachment) { $dispo = 'attachment'; $mailbody .= $eol; $mailbody .= "Content-Disposition: $dispo; filename={$attachment[2]}".$eol; $mailbody .= "Content-Type: {$attachment[1]}; name={$attachment[2]}".$eol; - + $mailbody .= 'Content-Transfer-Encoding: '.$attachment[3].$eol; $mailbody .= $eol; $mailbody .= $attachment[0]; @@ -144,17 +146,17 @@ class mail $mailbody .= "--$mime_boundary_mixed"; } } - + // Attachments Binary - if (is_array($this->attachments) && (count($this->attachments) > 0)) + if (is_array($this->attachments) && (count($this->attachments) > 0)) { - foreach ($this->attachments as $attachment) + foreach ($this->attachments as $attachment) { $dispo = empty($attachment[3]) ? 'attachment' : 'inline'; $mailbody .= $eol; $mailbody .= "Content-Disposition: $dispo; filename={$attachment[2]}".$eol; - $mailbody .= "Content-Type: {$attachment[1]}; name={$attachment[2]}".$eol; - if (!empty($attachment[3])) + $mailbody .= "Content-Type: {$attachment[1]}; name={$attachment[2]}".$eol; + if (!empty($attachment[3])) { $mailbody .= "Content-ID: <{$attachment[3]}>".$eol; } @@ -166,15 +168,15 @@ class mail } } $mailbody .= "--".$eol; - + // Subject Encoding setzen $subject = "=?UTF-8?B?".base64_encode($this->subject)."?="; - + // Senden if(mail($this->to, $subject, $mailbody, $header)) return true; - else - return false; + else + return false; } /** @@ -187,7 +189,7 @@ class mail $this->textContent[2] = $encoding; return true; } - + /** * Setzt den HTMLText fuer ein Mail */ @@ -198,7 +200,7 @@ class mail $this->htmlContent[2] = $encoding; if (empty($this->textContent[0])) $this->setTextContent(strip_tags($html), $charset, $encoding); - + return true; } @@ -211,27 +213,27 @@ class mail */ public function addAttachmentBinary($file, $type, $name, $ContentID = "") { - if (!file_exists($file)) + if (!file_exists($file)) { $this->errormsg = 'Attachment wurde nicht gefunden'; return false; } - + $handle = fopen($file,'rb'); - if (!$handle) + if (!$handle) { $this->errormsg = 'Fehler beim Oeffnen der Datei'; return false; } - + $file_content = fread($handle,filesize($file)); @fclose($handle); - + $attachment_string = chunk_split(base64_encode($file_content)); $this->attachments[] = Array($attachment_string, $type, $name, $ContentID); return true; } - + /** * Fuegt ein Bild zum Mail hinzu * $image image-URL @@ -242,16 +244,16 @@ class mail public function addEmbeddedImage ($image, $type, $name = '', $ContentID) { $image_string = file_get_contents($image); - if (!$image_string) + if (!$image_string) { $this->errormsg = 'Fehler beim Einlesen der Datei'; return false; } - + $image_b64 = chunk_split(base64_encode($image_string), 76, "\n"); $this->attachments[] = Array($image_b64, $type, $name, $ContentID); } - + /** * Fuegt ein Attachment zum Mail hinzu * $content @@ -272,14 +274,14 @@ class mail $this->replyTo = $repl; return true; } - + /** * Setzt die CC Empfaenger */ public function setCCRecievers($rcvs) { $this->CC_recievers = ''; - if (is_array($rcvs)) + if (is_array($rcvs)) { foreach ($rcvs as $rcv) $this->CC_recievers .= ",$rcv"; @@ -291,14 +293,14 @@ class mail } return true; } - + /** * Setzt die BCC Empfaenger */ public function setBCCRecievers($rcvs) { $this->BCC_recievers = ''; - if (is_array($rcvs)) + if (is_array($rcvs)) { foreach ($rcvs as $rcv) $this->BCC_recievers .= ",$rcv";