<!--- 
  Filename: CheckMailLogin.cfm
  Author:   Nate Weiss (NMW)
  Purpose:  Provides a login form for the simple POP client
--->

<!--- If user is submitting username/password form --->
<CFIF IsDefined("FORM.POPServer")>
  <!--- Retain username, password, server in SESSION --->
  <CFSET SESSION.Mail = StructNew()>
  <CFSET SESSION.Mail.POPServer = FORM.POPServer>
  <CFSET SESSION.Mail.Username  = FORM.Username>
  <CFSET SESSION.Mail.Password  = FORM.Password>
  <!--- Remember server and username for next time --->  
  <CFSET CLIENT.MailServer      = FORM.POPServer>
  <CFSET CLIENT.MailUsername    = FORM.Username>

<CFELSE>  
  <!--- Use server/username from last time, if available --->
  <CFPARAM NAME="CLIENT.MailServer" TYPE="string" DEFAULT="">
  <CFPARAM NAME="CLIENT.MailUsername" TYPE="string" DEFAULT="">
  
  <!--- Simple form for user to provide mailbox info --->
  <CFFORM ACTION="#CGI.SCRIPT_NAME#" METHOD="POST">
    <P>To access your mail, please provide the 
    server, username and password.<BR>
    
    <!--- FORM field: POPServer --->
    <P>Mail Server:<BR>
    <CFINPUT TYPE="Text" NAME="POPServer" 
      VALUE="#CLIENT.MailServer#" REQUIRED="Yes" 
      MESSAGE="Please provide your mail server."> 
    (example: pop.yourcompany.com)<BR>
  
    <!--- FORM field: Username --->      
    Mailbox Username:<BR>
    <CFINPUT TYPE="Text" NAME="Username"
      VALUE="#CLIENT.MailUsername#" REQUIRED="Yes"
      MESSAGE="Please provide your username."> 
    (yourname@yourcompany.com)<BR>
  
    <!--- FORM field: Password --->      
    Mailbox Password:<BR>
    <CFINPUT TYPE="Password" NAME="Password"
      REQUIRED="Yes" 
      MESSAGE="Please provide your username."><BR>
      
    <INPUT TYPE="Submit" VALUE="Check Mail"><BR>
  </CFFORM>
  
  </BODY></HTML>
  <CFABORT>
</CFIF>

