setTo($inTo); $this->setFrom($inFrom); $this->setSubject($inSubject); $this->setBody($inBody); } /* * Simple email address validator */ function _checkEmail($inEmail) { if( preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $inEmail) ){ list($username,$domain)=split('@',$inEmail); if( !checkdnsrr($domain,'MX') ) { return false; } return true; } return false; } /* * Validates and sets the To: line address */ function setTo($inTo) { if ( $this->_checkEmail($inTo) ) { return false; } $this->to = $inTo; return true; } /* * Gets the To: line address */ function getTo() { return $this->to; } /* * Validates and sets the From: line address */ function setFrom($inFrom) { if ( $this->_checkEmail($inFrom) ) { return false; } $this->from = $inFrom; return true; } /* * Gets the From: line address */ function getFrom() { return $this->from; } /* * Sets the subject line value */ function setSubject($inSubject) { $this->subject = $inSubject; return true; } /* * Gets the subject line value */ function getSubject() { return $this->subject; } /* * Sets arbitrary header lines (must be formated correctly with \r\n per line) */ function setHeaders($inHeaders) { $this->headers = $inHeaders; return true; } /* * Gets the arbitrary header lines */ function getHeaders() { return $this->headers; } /* * Sets the email body */ function setBody($inBody) { $this->body = $inBody; return true; } /* * Gets the email body */ function getBody() { return $this->body; } /* * Sends the email */ function send() { if ( $this->getFrom() != '' ) { $this->setHeaders( 'From: ' . $this->getFrom() . "\r\n" . 'Reply-To: ' . $this->getFrom() . "\r\n" ); } return mail( $this->getTo(), $this->getSubject(), $this->getBody(), $this->getHeaders() ); } } ?>