Skip to content

Instantly share code, notes, and snippets.

@allen501pc
Created June 18, 2012 04:11
Show Gist options
  • Save allen501pc/2946795 to your computer and use it in GitHub Desktop.
Save allen501pc/2946795 to your computer and use it in GitHub Desktop.
POP3 Authentication for NCHU.
<?php
/* Program: Authenticate E-Mail for NCHU by POP3
* Author: Jyun-Yao Huang (Allen, allen501pc@gmail.com)
* Date: 18th June, 2012
*/
list($user,$domain) = @explode("@",$_POST['email']);
//list($user,$domain) = @explode("@","your @mail.nchu.edu.tw here");
$answer="";
$password= $_POST['emailpassword'];
//$password= "your test password here";
$errno=0;
$errstr="";
$fp = @fsockopen($domain,110,$errno, $errstr,10);
$answer1=@fgets($fp,128);
@fwrite($fp,"user $user\n");
$answer=@fgets($fp,128);
@fwrite($fp,"pass $password\n");
$answer=@fgets($fp,128);
@fclose($fp);
// If the authentication is true, then output "true", or "false".
if(strlen(stristr($answer,"OK"))>0)
echo "true";
else
echo "false";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment