From e074a034182448035337da2faef72a4b5d74e7dc Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 29 Jan 2006 17:13:08 +0000 Subject: [PATCH] Adding structure for all the features that are to come --- mail.php | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 8 deletions(-) diff --git a/mail.php b/mail.php index 84c5de5..bf0281c 100644 --- a/mail.php +++ b/mail.php @@ -48,11 +48,11 @@ class Mail var $registry = null; /** - * The message recipient's email address - * @var string + * The message recipient's email address in the form of array(email => name) + * @var array * @access private */ - var $to = ''; + var $to = array(); /** * The subject of the message @@ -62,11 +62,18 @@ class Mail var $subject = ''; /** - * Body of the message + * Body plain-text of the message + * @var string + * @access private + */ + var $bodytext = ''; + + /** + * HTML multi-part body of the message * @var string * @access private */ - var $body = ''; + var $bodyhtml = ''; /** * The message sender's email address @@ -89,18 +96,26 @@ class Mail */ var $headers = ''; + /** + * Whether to send the message as HTML or plain-text + * @var bool + * @access private + */ + var $sendhtml = false; + /** * Fields array that is used in this module * @var array * @access private */ var $fields = array( - 'to' => array(REQ_YES, null, false), 'subject' => array(REQ_YES, null, false), - 'body' => array(REQ_YES, null, false), + 'bodytext' => array(REQ_YES, null, false), + 'bodyhtml' => array(REQ_NO, null, false), 'from' => array(REQ_YES, null, false), 'fromname' => array(REQ_NO, null, false), - 'headers' => array(REQ_NO, null, false) + 'headers' => array(REQ_NO, null, false), + 'sendhtml' => array(REQ_NO, null, false) ); // ################################################################### @@ -150,6 +165,61 @@ class Mail return $this->registry->do_get($fieldname, 'mail'); } + // ################################################################### + /** + * Adds a to address + * + * @access public + * + * @param string Name to send to + * @param string Email address + */ + function to_add($name, $address) + { + if (isset($this->to["$address"]) AND $name !== null) + { + return; + } + + if ($this->registry->modules['functions']->is_valid_email($address)) + { + $this->to["$address"] = $name; + } + } + + // ################################################################### + /** + * Removes a to address by email; if FALSE, it will clear the array + * + * @access public + * + * @param string Email address to remove, or FALSE to clear array + */ + function to_remove($address) + { + if ($address === false) + { + $this->to = array(); + } + else + { + unset($this->to["$address"]); + } + } + + // ################################################################### + /** + * Returns the list of "to" addresses + * + * @access public + * + * @return array List of to-addresses + */ + function to_fetch() + { + return $this->to; + } + // ################################################################### /** * Sends an email to the specified address with the specified -- 2.22.5