<?php

// Inbox

// Display Messages  

// mail.host.com
$host = "mail.com";

// username
$username = "vizz";

$password = "vizz";

// make connection

$inbox = @imap_open ("{". $host . "/pop3:110}",$username, $password)
or header("Could not connect. Somethings wrong !");

$total = imap_num_msg($inbox);

?>

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">

<!--check all messages-->
<script language=javascript>
<!--
function toggle()
{
for( var i = 0; i < document.form1.elements.length; i++ )
document.form1.elements[i].checked = document.form1.tog.checked;
}
//--></script>



</head>

<body bgcolor="White"> 
				
	<table width="70%"  cellpadding="2" cellspacing="2" align="left">
	<tr>
	<td>
	
	<?php
	// header
	$title = "Inbox ($total total)";
	?>
	
	<table width="100%" border="0" cellspacing="0" cellpadding="6" >
		<tr bgcolor="#FF6600"><td valign="top" align="center" width="100%">&nbsp;</td>
		
			<td valign="top" align="center">
				<a class="menu" href="compose.php" border="0">
				<font face="Verdana" size="-2">Compose</font></a>
			</td>
			
			<td valign="top" align="center">
				<a class="menu" href="javascript:document.forms[0].submit()">
				<font face="Verdana" size="-2">Delete</font></a>
			</td>
			
			<td valign="top" align="center">
				<a class="menu" href="inbox.php">
				<font face="Verdana" size="-2">Send/Receive</font></a>
			</td>
		</tr>
	</table>
	<?php 
	if ($total > 0)
	{
	?>
	<table width="100%" border="0" cellspacing="0" cellpadding="5">
	<form action="delete.php" name="form1" method="post">
	
	<tr bgcolor="#012752">
	<td width="3%"><font size="-1">
	<input type=checkbox name=tog onClick="javascript:toggle();">&nbsp;</font></td>
	<td width="3%"><font size="-1">&nbsp;</font></td>
	<td width="29%"><font face="Arial" color="#ffffff" size="-1">
	<b>From</b></font></td> 
	<td width="34%"><font face="Arial" color="#ffffff" size="-1">
	<b>Subject</b></font></td>
	<td width="21%"><font face="Arial" color="#ffffff" size="-1">
	<b>Date</b></font></td>
	<td width="10%"><font face="Arial" color="#ffffff" size="-1">
	<b>Size</b></font></td>
	</tr>
	
	
	
	<?php
	for($x=$total; $x>0; $x--) 
	{
	$headers = imap_header($inbox, $x);
	$structure = imap_fetchstructure($inbox, $x);
	
	// rotate cell background color
	if ($bgColor == "#FFFFFF") {
	$bgColor = "#d8d8d8";
	} else {
	$bgColor = "#FFFFFF";
	}
	$overview=imap_fetch_overview($inbox,$x);
	$size=sizeof($overview);
	
	for($i=$size-1;$i>=0;$i--)
	$val=$overview[$i];
	$msg=$val->id;
	$from=$val->from;
	$date=$val->date;
	$subject=$val->subject;
	$seen=$val->seen;
	$Recent=$val->Recent;
	$from = ereg_replace("\"","",$from); 
	// make date display
	list($dayName,$day,$month,$year,$time) = split(" ",$date); 
	$time = substr($time,0,5);
	$date = $day ." ". $month . " ".$time;
	// restrict subject lenght 
	if (strlen($subject) > 30) {
	$subject = substr($subject,0,29) ."...";
	}
	?>
	<tr bgcolor="<?php echo $bgColor; ?>">
	<td align="right" valign="top">
	<input type="Checkbox" name="dmsg[]" value="<?php echo $x; ?>">
	</td>
	<td valign="center">
	</td>
	<td valign="top">
	<font face="Arial" size="-1">
	<?php echo "$from"; ?></font>
	</td>
	<td valign="top"><font face="Arial" size="-1">
	<a href="readmessage.php?id=<?php echo "$x"; ?>">
	<?php 
	// correction for empty subject
	if ($subject == "")
	{
	echo "No subject";
	}
	else
	{
	echo $subject; 
	}
	?>
	</a>
	</font>
	</td><td valign="top"><font face="Arial" size="-1">
	<?php echo $date; ?></font>
	</td><td valign="top"><font face="Arial" size="-1">
	<?php
	// message size
	echo ceil(($structure->bytes/1024)), "KB"; 
	?>
	</font>
	</td></tr>
	<?php
	}
	// clean up
	imap_close($inbox);
	?> 
	</form></table>
	<?php
	// if mailbox is empty
	}
	else
	{
	echo "<font face=Arial size=-1>You have no mail at this time</font>";
	}
	?>
	
	</td></tr></table>
		
</body>
</html>

This is my code that list out emails in inbox. But I am unable to read any one email from list.

Can anyone tell me how to read email with parsing?

so i have similar problem with this, but after some time i started to learn Zend Framework. And after some tries, i decide to make company webmail.. and i have no problem with it..
our compaany webmail was on gmail.
if you do not to learn whole framework, you can use only the mail classes and it's dependencies..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.