An email that can be collected online
I can't accept mine's letter. You can consider using BASE64 to decode what dongdong to achieve. specifically I forgot.
Just write it out. Not very mature yet.
Input.html
////////////////////////////////////////////////////
<title>pop Mail form</title>
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
<body bgcolor= "#FFFFFF" >
<form method= "POST" action= "check.php" >
<table width= "78%" >
<tr>
<TD width= "49%" height= "> Please enter your email account information:</td>
<TD width= "51%" height= "> </td>
</tr>
<tr>
<TD width= "49%" >
<div align= "Right" > Username:</div>
</td>
<TD width= "51%" >
<input type= "text" name= "username" >
</td>
</tr>
<tr>
<TD width= "49%" >
<div align= "Right" > Password:</div>
</td>
<TD width= "51%" >
<input type= "Password" name= "passwd" >
</td>
</tr>
<tr>
<TD width= "49%" >
<div align= "Right" > host name:</div>
</td>
<TD width= "51%" >
<input type= "text" name= "Pophost" >
</td>
</tr>
<tr>
<TD width= "49%" >
<div align= "center" >
<input type= "Submit" name= "Check" value= "OK" >
</div>
</td>
<TD width= "51%" >
<div align= "center" >
<input type= "reset" name= "reset" value= "Again" >
</div>
</td>
</tr>
</table>
</form>
</body>
check.php
/////////////////////////////////////////
?
Include ("./mail.php");
if ($check) {
$pop 3 = Pop3_open ("$pophost", "110");
if (! $pop 3) {
printf ([ERROR] failed to connect properly with the host! <br>\n ");
return 0;
}
if (!pop3_user ($pop 3, "$username")) {
printf ("[ERROR] Wrong user name" lt;br>\n ");
return 0;
}
if (!pop3_pass ($pop 3, "$passwd")) {
printf ("[ERROR] Password error!") <br>\n ");
return 0;
}
$articles = Pop3_list ($pop 3);
if (! $articles) {
printf ("[ERROR] List error!") <br>\n ");
return 0;
}
Print "<table width=\" 100%\ "border=1>";
print "<tr><td> status </td><td> sender </td><td> theme </td></tr>";
for ($i = 1; $i < $articles ["Count"] + 1; $i + +)
{
$data = Pop3_retr ($pop 3, $i);
if (substr ($data [9],8,2) = = "RO") $read = "read";
else $read = "unread";
Print "<tr><td> $read </td><td> $data [5]</td><td><a
Href=\ "readmail.php?username= $username &passwd= $passwd &pophost= $pophost &no= $i \" > $data [8]</a ><
/td></tr> ";
}
print "</table>";
}
?>
mail.php
/////////////////////////////////////////
?
function Pop3_open ($server, $port)
{
Global $POP 3_global_status;
$pop 3 = Fsockopen ($server, $port);
if ($pop 3 <= 0) return 0;
$line = Fgets ($pop 3, 1024);
$POP 3_global_status[$pop 3]["lastresult"] = substr ($line, 0, 1);
$POP 3_global_status[$pop 3]["lastresulttxt"] = substr ($line, 0, 1024);
if ($POP 3_global_status[$pop 3]["Lastresult"] <> "+") return 0;
return $pop 3;
}
function Pop3_user ($pop 3, $user)
{
Global $POP 3_global_status;
Fputs ($pop 3, "USER $user \ r \ n");
$line = Fgets ($pop 3, 1024);
$POP 3_global_status[$pop 3]["lastresult"] = substr ($line, 0, 1);
$POP 3_global_status[$pop 3]["lastresulttxt"] = substr ($line, 0, 1024);
if ($POP 3_global_status[$pop 3]["Lastresult"] <> "+") return 0;
return 1;
}
function Pop3_pass ($pop 3, $pass)
{
Global $POP 3_global_status;
Fputs ($pop 3, "pass $pass \ r \ n");
$line = Fgets ($pop 3, 1024);
$POP 3_global_status[$pop 3]["lastresult"] = substr ($line, 0, 1);
$POP 3_global_status[$pop 3]["lastresulttxt"] = substr ($line, 0, 1024);
if ($POP 3_global_status[$pop 3]["Lastresult"] <> "+") return 0;
return 1;
}
function Pop3_stat ($pop 3)
{
Global $POP 3_global_status;
Fputs ($pop 3, "stat\r\n");
$line = Fgets ($pop 3, 1024);
$POP 3_global_status[$pop 3]["lastresult"] = substr ($line, 0, 1);
$POP 3_global_status[$pop 3]["lastresulttxt"] = substr ($line, 0, 1024);
if ($POP 3_global_status[$pop 3]["Lastresult"] <> "+") return 0;
if (!eregi ("+ok (. *) (. *)", $line, $regs))
return 0;
return $regs [1];
}
function Pop3_list ($pop 3)
{
Global $POP 3_global_status;
Fputs ($pop 3, "list\r\n");
$line = Fgets ($pop 3, 1024);
$POP 3_global_status[$pop 3]["lastresult"] = substr ($line, 0, 1);
$POP 3_global_status[$pop 3]["lastresulttxt"] = substr ($line, 0, 1024);
if ($POP 3_global_status[$pop 3]["Lastresult"] <> "+") return 0;
$i = 0;
while (substr ($line = fgets ($pop 3, 1024), 0, 1) <> ".")
{
$articles [$i] = $line;
$i + +;
}
$articles ["count"] = $i;
return $articles;
}
function Pop3_retr ($pop 3, $NR)
{
Global $POP 3_global_status;
Fputs ($pop 3, "RETR $nr \ r \ n");
$line = Fgets ($pop 3, 1024);
$POP 3_global_status[$pop 3]["lastresult"] = substr ($line, 0, 1);
$POP 3_global_status[$pop 3]["lastresulttxt"] = substr ($line, 0, 1024);
if ($POP 3_global_status[$pop 3]["Lastresult"] <> "+") return 0;
while (substr ($line = fgets ($pop 3, 1024), 0, 1) <> ".")
{
$data [$i] = $line;
$i + +;
}
$data ["count"] = $i;
return $data;
}
function Pop3_dele ($pop 3, $NR)
{
Global $POP 3_global_status;
Fputs ($pop 3, "DELE $nr \ r \ n");
$line = Fgets ($pop 3, 1024);
$POP 3_global_status[$pop 3]["lastresult"] = substr ($line, 0, 1);
$POP 3_global_status[$pop 3]["lastresulttxt"] = substr ($line, 0, 1024);
if ($POP 3_global_status[$pop 3]["Lastresult"] <> "+") return 0;
return 1;
}
function Pop3_quit ($pop 3)
{
Global $POP 3_global_status;
Fputs ($pop 3, "quit\r\n");
$line = Fgets ($pop 3, 1024);
$POP 3_global_status[$pop 3]["lastresult"] = substr ($line, 0, 1);
$POP 3_global_status[$pop 3]["lastresulttxt"] = substr ($line, 0, 1024);
if ($POP 3_global_status[$pop 3]["Lastresult"] <> "+") return 0;
return 1;
}
function Smtp_open ($server, $port)
{
Global $SMTP _global_status;
$SMTP = Fsockopen ($server, $port);
if ($SMTP < 0) return 0;
$line = fgets ($SMTP, 1024);
$SMTP _global_status[$SMTP] ["lastresult"] = substr ($line, 0, 1);
$SMTP _global_status[$SMTP] ["lastresulttxt"] = substr ($line, 0, 1024);
if ($SMTP _global_status[$smtp] ["Lastresult"] <> "2") return 0;
return $SMTP;
}
function Smtp_helo ($SMTP)
{
Global $SMTP _global_status;
/* ' localhost ' always works [Unk] * *
Fputs ($SMTP, "Helo localhost\r\n");
$line = fgets ($SMTP, 1024);
$SMTP _global_status[$SMTP] ["lastresult"] = substr ($line, 0, 1);
$SMTP _global_status[$SMTP] ["lastresulttxt"] = substr ($line, 0, 1024);
if ($SMTP _global_status[$smtp] ["Lastresult"] <> "2") return 0;
return 1; }
function Smtp_ehlo ($SMTP)
{
Global $SMTP _global_status;
/* Yes, let's use the "Helo" for now. Until we need the
Extra Func ' s [Unk]
*/
Fputs ($SMTP, "Helo localhost\r\n");
$line = fgets ($SMTP, 1024);
$SMTP _global_status[$SMTP] ["lastresult"] = substr ($line, 0, 1);
$SMTP _global_status[$SMTP] ["lastresulttxt"] = substr ($line, 0, 1024);
if ($SMTP _global_status[$smtp] ["Lastresult"] <> "2") return 0;
return 1;
}
function Smtp_mail_from ($SMTP, $from)
{
Global $SMTP _global_status;
Fputs ($SMTP, "MAIL from: < $from >\r\n");
$line = fgets ($SMTP, 1024);
$SMTP _global_status[$SMTP] ["lastresult"] = substr ($line, 0, 1);
$SMTP _global_status[$SMTP] ["lastresulttxt"] = substr ($line, 0, 1024);
if ($SMTP _global_status[$smtp] ["Lastresult"] <> "2") return 0;
return 1;
}
function smtp_rcpt_to ($SMTP, $to)
{
Global $SMTP _global_status;
Fputs ($SMTP, "RCPT to: < $to >\r\n");
$line = fgets ($SMTP, 1024);
$SMTP _global_status[$SMTP] ["lastresult"] = substr ($line, 0, 1);
$SMTP _global_status[$SMTP] ["lastresulttxt"] = substr ($line, 0, 1024);
if ($SMTP _global_status[$smtp] ["Lastresult"] <> "2") return 0;
return 1;
}
function Smtp_data ($SMTP, $subject, $data)
{
Global $SMTP _global_status;
Fputs ($SMTP, "data\r\n");
$line = fgets ($SMTP, 1024);
$SMTP _global_status[$SMTP] ["lastresult"] = substr ($line, 0, 1);
$SMTP _global_status[$SMTP] ["lastresulttxt"] = substr ($line, 0, 1024);
if ($SMTP _global_status[$smtp] ["Lastresult"] <> "3") return 0;
Fputs ($SMTP, "mime-version:1.0\r\n");
Fputs ($SMTP, "Subject: $subject \ r \ n");
Fputs ($SMTP, "$data \r\n\r\n");
Fputs ($SMTP, ". \ r \ n");
$line = fgets ($SMTP, 1024);
if (substr ($line, 0, 1) <> "2")
return 0;
return 1;
}
function Smtp_quit ($SMTP)
{
Global $SMTP _global_status;
Fputs ($SMTP, "quit\r\n");
$line = fgets ($SMTP, 1024);
$SMTP _global_status[$SMTP] ["lastresult"] = substr ($line, 0, 1);
$SMTP _global_status[$SMTP] ["lastresulttxt"] = substr ($line, 0, 1024);
if ($SMTP _global_status[$smtp] ["Lastresult"] <> "2") return 0;
return 1;
}
function Mail_parse ($mail)
{
$newmail = explode ("\ n", $mail);
$count = 0;
$result =
$newmail [4]. " \ n ". $newmail [6]." \ n ". $newmail [7]." \ n ". $newmail [8]." \ n ";
return $result;
}
?>
readmail.php
?
Include ("./mail.php");
$pop 3 = Pop3_open ("$pophost", "110");
if (! $pop 3) {
printf ([ERROR] failed to connect properly with the host! <br>\n ");
return 0;
}
if (!pop3_user ($pop 3, "$username")) {
printf ("[ERROR] Error username!") <br>\n ");
return 0;
}
if (!pop3_pass ($pop 3, "$passwd")) {
printf ("[ERROR] Password error!") <br>\n ");
return 0;
}
$data = Pop3_retr ($pop 3, $no);
if (substr ($data [9],8,2) = = "RO") $read = "read";
else $read = "unread";
$countall = count ($data);
print "<CENTER><H2> letter content </H2></CENTER><BR>";
Print "<table width =\" 100%\ "border=1>";
Print "<tr><td> sender </td><td>";
$mailfrom = substr ($data [5],5,strlen ($data [5])-5);
Print "$mailfrom <br>\n";
print "</td></tr>";
Print "<tr><td> receiving person </td><td>";
$mailto = substr ($data [7],3,strlen ($data [7])-3);
Print "$mailto <br>\n";
print "</td></tr>";
Print "<tr><td> theme </td><td>";
$subject = substr ($data [8],8,strlen ($data [8])-8);
Print "$subject <br>\n";
print "</td></tr>";
Print "<tr><td> content </td><td>";
for ($count =10; $count < $countall; $count + +)
Print "$data [$count]<br>\n";
print "</td></tr>";
print "<table>";
Pop3_quit ($pop 3);
?>