Created
April 8, 2017 15:08
-
-
Save kharysharpe/e352006bf4e9ce01e49a5a7c6818e5a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Source: http://www.web-max.ca/PHP/email_1.php | |
$username = ''; | |
$password = ''; | |
$server = 'pop3.example.com' | |
$port = 110; | |
$cmd = array(); | |
$cmd[] = "USER $username\r\n"; | |
$cmd[] = "PASS $password\r\n"; | |
$cmd[] = "STAT\r\n"; | |
$cmd[] = "QUIT\r\n"; | |
$fp = fsockopen($server, $port); | |
if(!$fp) { | |
print("Error connecting to server $server"); | |
} else { | |
$ret = fgets($fp, 1024); | |
foreach($cmd as $ret) { | |
fputs($fp, $ret); | |
$line = fgets($fp, 1024); | |
print($line."<br>"); | |
if($ret == "STAT\r\n") { | |
$fields = explode(" ", $line); | |
$num_mails = $fields[1]; | |
for($i = 1; $i <= $num_mails; $i++) { | |
fputs($fp, "DELE $i\r\n"); | |
$line = fgets($fp, 1024); | |
} | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment