protected function validate($address) {
        if (!$this->record) {
            // The record does not exist, so there is nothing to validate against.
            return self::VALIDATION_INVALID_ADDRESS_FORMAT;
        }

        // Build the list of validation errors.
        $returnvalue = 0;

        if (!$this->handler) {
            $returnvalue += self::VALIDATION_UNKNOWN_HANDLER;
        } else if (!$this->handler->enabled) {
            $returnvalue += self::VALIDATION_DISABLED_HANDLER;
        }

        if (!isset($this->record->data) || !$this->record->data) {
            $returnvalue += self::VALIDATION_UNKNOWN_DATAKEY;
        } else if ($this->record->data->expires != 0 && $this->record->data->expires < time()) {
            $returnvalue += self::VALIDATION_EXPIRED_DATAKEY;
        } else {

            if (!$this->record->user) {
                $returnvalue += self::VALIDATION_UNKNOWN_USER;
            } else {
                if ($this->record->user->deleted || !$this->record->user->confirmed) {
                    $returnvalue += self::VALIDATION_DISABLED_USER;
                }

                $userkey = get_user_key('messageinbound_handler', $this->record->user->id);
                $hashvalidation = substr(md5($this->record->data->datakey . $userkey), 0, self::HASHSIZE) == $this->record->datakey;
                if (!$hashvalidation) {
                    // The address data did not check out, so the originator is deemed invalid.
                    $returnvalue += self::VALIDATION_INVALID_HASH;
                }

                if ($this->handler->validateaddress) {
                    // Validation of the sender's e-mail address is also required.
                    if ($address !== $this->record->user->email) {
                        // The e-mail address of the originator did not match the
                        // address held on record for this user.
                        $returnvalue += self::VALIDATION_ADDRESS_MISMATCH;
                    }
                }
            }
        }

        return $returnvalue;
    }