Zend - The PHP Company




Email

Add Code


Simple Mail Checker  

Type: code fragment
Added by: lentin64
Entered: 12/10/2001
Last modified: 31/10/2000
Rating: - (fewer than 3 votes)
Views: 7704
Using only 1 file, you can use this to check your mail. However, for example: It does not feature replying or Sent mail or trash.


<?php 

$SERVER 
"my.server.com";
$TYPE "POP3"//this can be IMAP. Just put in: IMAP

if($php == "login.htm") {
if(!
$PHP_AUTH_USER) {
header("WWW-Authenticate: Basic realm="Webmail"");
header("HTTP/1.0 401 Unauthorized");
} else {
header("Location: $PHP_SELF?php=messages.htm");
}
} elseif(
$php == "messages.htm") {
if(
$TYPE == "POP3"){ $ms "{".$server.":110/pop3}INBOX"; } elseif($TYPE == "IMAP") { $ms "{".$server."}"; }
$mbox=imap_open($ms$PHP_AUTH_USER$PHP_AUTH_PW);
$head=imap_headers($mbox);
for(
$x=1$x count($head); $x++) {
$txt=($x-1); echo "<A HREF='$PHP_SELF?php=view.htm&num=$x'>$head[$txt]</A>&nbsp;&nbsp;<A href='$PHP_SELF?php=delete.htm&num=$x'>Delete</a><BR><BR>n";
}
} elseif(
$php == "view.htm") {
if(
$TYPE == "POP3"){ $ms "{".$server.":110/pop3}INBOX"; } elseif($TYPE == "IMAP") { $ms "{".$server."}"; }
$mbox=imap_open($ms$PHP_AUTH_USER$PHP_AUTH_PW);
$msg=imap_header($mbox);
$from=$msg->from[0];
echo 
"From: $from->mailbox@$from->host<BR>n";
echo 
"To: $msg->to<BR>n";
echo 
"Date: $msg->Date<BR>n";
echo 
"Subject: $msg->Subject<BR>n";
echo 
"<PRE>"; echo imap_body($mbox$num); echo "nn</PRE>";
echo 
"<a href='$PHP_SELF?php=messages.htm'>Back to INBOX</a>/<a href='$PHP_SELF?php=sendmail.htm'>Compose Message</a>";
} elseif(
$php == "delete.htm") {
if(
$TYPE == "POP3"){ $ms "{".$server.":110/pop3}INBOX"; } elseif($TYPE == "IMAP") { $ms "{".$server."}"; }
$mbox=imap_open($ms$PHP_AUTH_USER$PHP_AUTH_PW);
imap_delete($mbox$num);
imap_expunge($mbox);
header("Location: $PHP_SELF?php=messages.htm");
} elseif(
$php == "sendmail.htm") {
if(
$sendmail) { mail($to$subj$msg'FROM: '.$from); header("Location: $PHP_SELF?php=messages.htm"); }
echo 
"<form action='$PHP_SELF?php=sendmail.htm' method='post'>n";
echo 
"To: <input type='text' name='to'><BR>n";
echo 
"From: <input type='text' name='from'><BR>n";
echo 
"Subject: <input type='text' name='subj'><BR>n";
echo 
"<textarea rows=10 cols=40 name=msg></textarea><BR>n";
echo 
"<input type=submit value='send'></form>";
}
?>


Usage Example


No Example.


Rate This Script





Search



This Category All Categories