<?php
  header
('Content-Type: plain/text; charset=utf-8');

  
$mailServer=@$_POST['mail_server'];
  
$mailPort=@$_POST['mail_port'];
  
$mailType=@$_POST['mail_type'];
  
$mailSecurity=@$_POST['mail_security'];
  
$mailUsername=@$_POST['mail_username'];
  
$mailPassword=@$_POST['mail_password'];

  if (
get_magic_quotes_gpc())
  {
    
$mailServer=stripslashes($mailServer);
    
$mailPort=stripslashes($mailPort);
    
$mailType=stripslashes($mailType);
    
$mailSecurity=stripslashes($mailSecurity);
    
$mailUsername=stripslashes($mailUsername);
    
$mailPassword=stripslashes($mailPassword);
  }
  if (
$mailSecurity$mailSecurity='/'.$mailSecurity;

  if (
function_exists('imap_open'))
  {
    
$mbox=@imap_open('{'.$mailServer.':'.$mailPort.'/'.$mailType.$mailSecurity.'}INBOX',$mailUsername,$mailPassword,null,0);
    if (
$mbox==false)
    {
      
$errors=imap_errors();
      echo 
$errors[0];
    }
    else
    {
      @
imap_close($mbox);
      echo 
'OK';
    }
  }
  else
    echo 
'ERROR: imap library not loaded';
?>