From 7c32f7b873c36da7d3e3994540dbc82cd9770e29 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 29 Jan 2006 19:23:26 +0000 Subject: [PATCH] Making charset and delim settable --- mail.php | 60 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/mail.php b/mail.php index 54ad93c..52f67ff 100644 --- a/mail.php +++ b/mail.php @@ -103,6 +103,20 @@ class Mail */ var $sendhtml = false; + /** + * The new line delimiter used in the message + * @var string + * @access private + */ + var $delim = "\n"; + + /** + * Character set used to send messages with + * @var string + * @access public + */ + var $charset = 'iso-8859-1'; + /** * Fields array that is used in this module * @var array @@ -115,7 +129,9 @@ class Mail 'from' => array(REQ_YES, null, false), 'fromname' => array(REQ_NO, null, false), 'headers' => array(REQ_NO, null, false), - 'sendhtml' => array(REQ_NO, null, false) + 'sendhtml' => array(REQ_NO, null, false), + 'delim' => array(REQ_YES, null, true), + 'charset' => array(REQ_YES, null, true) ); // ################################################################### @@ -283,50 +299,48 @@ class Mail $this->subject = $this->_fetch_first_line($this->subject); $this->subject = trim($this->registry->unsanitize($this->subject)); - $delim = "\n"; - // sanitize the body - $this->bodytext = $this->registry->modules['functions']->convert_line_breaks($this->bodytext, $delim); + $this->bodytext = $this->registry->modules['functions']->convert_line_breaks($this->bodytext, $this->delim); $this->bodytext = trim($this->registry->unsanitize($this->bodytext, true)); // attach additional headers - $this->headers = $this->registry->modules['functions']->convert_line_breaks($this->headers, $delim); - $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; + $this->headers = $this->registry->modules['functions']->convert_line_breaks($this->headers, $this->delim); + $this->headers .= "From: \"{$this->fromname}\" <{$this->from}>" . $this->delim; + $this->headers .= "Return-Path: {$this->from}" . $this->delim; + $this->headers .= "X-Mailer: ISSO Mail Framework \$Revision$" . $this->delim; + $this->headers .= "MIME-Version: 1.0" . $this->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/alternative; boundary=\"$boundary\"" . $delim; + $this->headers .= "Content-Type: multipart/alternative; boundary=\"$boundary\"" . $this->delim; - $this->bodyhtml = $this->registry->modules['functions']->convert_line_breaks($this->bodyhtml, $delim); + $this->bodyhtml = $this->registry->modules['functions']->convert_line_breaks($this->bodyhtml, $this->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; + $body = "--$boundary" . $this->delim; + $body .= "Content-Type: text/plain; charset=\"" . $this->charset . "\"" . $this->delim; + $body .= "Content-Transfer-Encoding: 8bit" . $this->delim . $this->delim; + $body .= $this->bodytext . $this->delim; // add some space between the parts - $body .= $delim . $delim . $delim; + $body .= $this->delim . $this->delim . $this->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" . $this->delim; + $body .= "Content-Type: text/html; charset=\"" . $this->charset . "\"" . $this->delim; + $body .= "Content-Transfer-Encoding: 8bit" . $this->delim; + $body .= "Content-Disposition: inline" . $this->delim . $this->delim; + $body .= $this->bodyhtml . $this->delim; $body .= "--$boundary--"; } else { - $this->headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . $delim; + $this->headers .= "Content-Type: text/plain; charset=\"" . $this->charset . "\"" . $this->delim; $body = $this->bodytext; } - $this->headers .= "Content-Transfer-Encoding: 8bit" . $delim; + $this->headers .= "Content-Transfer-Encoding: 8bit" . $this->delim; $this->headers = trim($this->headers); -- 2.22.5