//Example code, assume that $username and $password is passed via FORM (hopefully SSL!)
//For more information see
http://us2.php.net/manual/en/function.imap-open.php//Assume file is named imaplogin.php
echo("\n");
echo("
IMAP Login\n");
echo("\n");
//Username & Password passed.
if($username && $password){
//Define your variables to suit your needs
$IMAPSERVER = "127.0.0.1";
$IMAPPORT = "143/notls";
$mbox = imap_open ("\{$IMAPSERVER:$IMAPPORT}", "$username", "$password",OP_HALFOPEN) || die("Invalid username or password: " . imap_last_error());
//Do stuff here, user/pass is good.
echo("Hi $username, welcome to the system.");
}else{
//Need login
echo("
\n");
}
echo("");
echo("\n");
?>