From 24d456adcfb12896bd12131f58cff0232ed16921 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 29 Jan 2006 18:51:48 +0000 Subject: [PATCH] This should be working... but it isn't --- mail.php | 56 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/mail.php b/mail.php index 584114c..f129b47 100644 --- a/mail.php +++ b/mail.php @@ -298,32 +298,68 @@ class Mail { $this->subject = trim($this->registry->unsanitize($this->_fetch_first_line($this->subject))); } - // sanitize the body - if (!$this->body) + + $delim = "\n"; + + // sanitize the body + if (!$this->bodytext) { $this->registry->debug("email: no body -> not sending"); return false; } else { - $this->body = $this->registry->modules['functions']->convert_line_breaks($this->body); - $this->body = trim($this->registry->unsanitize($this->body, true)); + $this->bodytext = $this->registry->modules['functions']->convert_line_breaks($this->bodytext, $delim); + $this->bodytext = trim($this->registry->unsanitize($this->bodytext, true)); } // attach additional headers $this->headers = $this->registry->modules['functions']->convert_line_breaks($this->headers); - $this->headers .= "From: \"{$this->fromname}\" <{$this->from}>\n"; - $this->headers .= "Return-Path: {$this->from}\n"; - $this->headers .= "X-Mailer: ISSO Mail Framework \$Revision$\n"; - $this->headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n"; - $this->headers .= "Content-Transfer-Encoding: 7bit\n"; + $this->headers .= "From: \"{$this->fromname}\" <{$this->from}>" . $delim; + $this->headers .= "Return-Path: {$this->from}" . $delim; + $this->headers .= "X-Mailer: ISSO Mail Framework \$Revision$" . $delim; + $this->headers .= "MIME-Version: 1.0" . $delim; + + // see if we need to use mime/multipart + if ($this->sendhtml AND $this->fields['bodyhtml'][2] == true) + { + $boundary = 'ISSO-MULTIPART-' . $this->registry->modules['functions']->rand(10); + $this->headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"" . $delim; + + $this->bodyhtml = $this->registry->modules['functions']->convert_line_breaks($this->bodyhtml, $delim); + + // first part of the message (plaintext) + $body = "--$boundary" . $delim; + $body .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $delim; + $body .= "Content-Transfer-Encoding: 8bit" . $delim . $delim; + $body .= $this->bodytext . $delim; + + // add some space between the parts + $body .= $delim . $delim . $delim; + + // second part (html) + $body .= "--$boundary" . $delim; + $body .= "Content-Type: text/html; charset=\"iso-8859-1\"" . $delim; + $body .= "Content-Transfer-Encoding: 8bit" . $delim; + $body .= "Content-Disposition: inline" . $delim . $delim; + $body .= $this->bodyhtml . $delim; + $body .= "--$boundary--"; + } + else + { + $this->headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $delim; + $body = $this->bodytext; + } + $this->headers .= "Content-Transfer-Encoding: 8bit" . $delim; $this->headers = trim($this->headers); + #echo $body; exit; + // attempt to send the mail! foreach ($tolist AS $address) { - if (mail($address, $this->subject, $this->body, $this->headers, "-f {$this->from}")) + if (mail($address, $this->subject, $body, $this->headers, "-f {$this->from}")) { $this->registry->debug("email: sent -> good"); return true; -- 2.43.5