Neue Mail Header hinzugefügt:

Precedence: bulk zur Markierung als Massenmail
Auto-Submitted: auto-generated zur Markierung als automatisch generiertes
E-Mail
This commit is contained in:
Andreas Österreicher
2018-09-20 18:31:32 +02:00
parent 1d74d6c758
commit fa52f3a34e
+40 -38
View File
@@ -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";