<%ARGS>
</%ARGS>

<%INIT>
my $CurrentUser = new RT::CurrentUser();

my $Email;

# whatever the argument, we want to find by email
for (keys %ARGS) {
  $Email = $ARGS{$_}, last
     if defined $ARGS{$_};
}

my $Users = RT::Users->new($CurrentUser);
$Users->Limit(FIELD => 'EmailAddress', OPERATOR => 'LIKE', VALUE => "\%$Email%");

my $users = qq{<ul class="contacts">};

while (my $User = $Users->Next()) {
    next if ($User->id == $RT::Nobody->id);

    # some cleaning on emailadress
    next if $User->EmailAddress !~ m{[a-zA-Z0-9_.-]+@[^.]+\.[^.]};
    next if $User->EmailAddress =~ m{[,?!/;\\]};

    my $email = $User->EmailAddress;
    $users .= qq{<li class="contact"><div class="email">$email</div></li>};
}

$users .= '</ul>';

$m->out($users);
$m->abort;

</%INIT>