From 5081f28001179a62057ce1a7d00f22975a5c5957 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 29 Jan 2006 19:16:55 +0000 Subject: [PATCH] Required fields are checked for being empty in set() which allows us to remove a lot of the emptyness checking in send() --- mail.php | 48 ++++++++++++------------------------------------ 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/mail.php b/mail.php index 7612f8c..9658267 100644 --- a/mail.php +++ b/mail.php @@ -147,6 +147,11 @@ class Mail */ function set($name, $value) { + if (empty($value) AND $this->fields["$name"][0] == REQ_YES) + { + trigger_error('Field ' . $name . ' cannot be empty', E_USER_ERROR); + } + $this->registry->do_set($name, $value, 'mail'); } @@ -268,50 +273,21 @@ class Mail // sanitize the from field $this->from = $this->_fetch_first_line($this->from); - if (!$this->from) - { - $this->registry->debug("email: no from -> not sending"); - return false; - } - else - { - $this->from = trim($this->registry->unsanitize($this->from)); - } + $this->from = trim($this->registry->unsanitize($this->from)); // sanitize the from name - if (!$this->fromname) - { - $this->fromname = $this->from; - } - else - { - $this->fromname = trim($this->registry->unsanitize($this->fromname)); - } + $this->fromname = $this->_fetch_first_line($this->fromname); + $this->fromname = ($this->fromname == '' ? $this->from : trim($this->registry->unsanitize($this->fromname))); // sanitize the subject - if (!$this->subject) - { - $this->registry->debug("email: no subject -> not sending"); - return false; - } - else - { - $this->subject = trim($this->registry->unsanitize($this->_fetch_first_line($this->subject))); - } + $this->subject = $this->_fetch_first_line($this->subject); + $this->subject = trim($this->registry->unsanitize($this->subject)); $delim = "\n"; // sanitize the body - if (!$this->bodytext) - { - $this->registry->debug("email: no body -> not sending"); - return false; - } - else - { - $this->bodytext = $this->registry->modules['functions']->convert_line_breaks($this->bodytext, $delim); - $this->bodytext = trim($this->registry->unsanitize($this->bodytext, 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); -- 2.22.5