اخي العزيز شكرا لك ولكن لكي يكون العمل سريع دعني اريك ما وصلت له .
اولا انا في حال اردت ان استخدم ال Imap كما تفضلت انت كنت بحاجة هنا الى الاتصال بسيرفر يعني ال pop3
صح والذهاب الى ال id الخاص بالرسالة
كلة لهون مزبوط ولكن
اقول لك انه انا لا اريد الالاتصال بسيرفر معين
لانه الرسالة كلها عندي كما شايف فوق ومخزنها بمتغير اسمة message$
ولكي ترى اني عملت بالموضوع فهاك كود يقوم باستجلاب عناصر الرسالة
كود PHP:
<html>
<head>
</head>
<body bgcolor="White">
<?
require_once("message.php");
$inbox = $message;
?>
<?
$id="1";
// get message headers and structure
$headers = imap_header($inbox, $id);
$structure = imap_fetchstructure($inbox, $id);
// if multipart, parse
if(sizeof($structure->parts) > 1)
{
$sections = parse($structure);
$attachments = get_attachments($sections);
}
?>
<table width="100%" border="0" cellspacing="3" cellpadding="5">
<!-- command buttons -->
<tr>
<td width="100%"> </td>
<td valign=top align=center><a href="compose.php"><img
src="images/compose.gif" width=50 height=50 alt="" border="0"><br><font
face="Verdana" size="-2">Compose</font></a></td>
<td valign=top align=center><a href="reply.php?id=<? echo $id; ?>"><img
src="images/reply.gif" width=50 height=50 alt="" border="0"><br><font
face="Verdana" size="-2">Reply</font></a></td>
<td valign=top align=center><a href="forward.php?id=<? echo $id; ?>"><img
src="images/forward.gif" width=50 height=50 alt="" border="0"><br><font
face="Verdana" size="-2">Forward</font></a></td>
<td valign=top align=center><a href="delete.php?dmsg[]=<? echo $id;
?>"><img src="images/delete.gif" width=50 height=50 alt=""
border="0"><br><font face="Verdana" size="-2">Delete</font></a></td>
<td valign=top align=center><a href="list.php"><img src="images/list.gif"
width=50 height=50 alt="" border="0"><br><font face="Verdana"
size="-2">Messages </font></a></td>
</tr>
</table>
<table border="0" cellspacing="1" cellpadding="5" width="100%">
<tr>
<td valign=top><font face="Verdana" size="-1"><b>From: </b></font></td>
<td valign=top width=100%><font face="Verdana" size="-1"><? echo
htmlspecialchars($headers->fromaddress);
?></font></td>
</tr>
<tr>
<td valign=top><font face="Verdana" size="-1"><b>To:</b></font></td>
<td valign=top><font face="Verdana" size="-1"><? echo
htmlspecialchars($headers->toaddress); ?>
</font>
</td>
</tr>
<?php
if($headers->ccaddress)
{
?>
<tr>
<td valign=top><font face="Verdana" size="-1"><b>Cc: </b></font></td>
<td valign=top><font face="Verdana" size="-1"><? echo
htmlspecialchars($headers->ccaddress); ?>
</tr>
<?
}
?>
<tr>
<td valign=top><font face="Verdana" size="-1"><b>Date: </b></font></td>
<td valign=top><font face="Verdana" size="-1"><? echo
$headers->Date;?></font></td>
</tr>
<tr>
<td valign=top><font face="Verdana" size="-1"><b>Subject: </b></font></td>
<td valign=top><font face="Verdana" size="-1">
<?
// correction for empty subject
if ($headers->Subject)
{
echo $headers->Subject;
}
else
{
echo "No subject";
}
?>
</font></td>
</tr>
<tr>
<td colspan=2 valign="TOP"><pre><font face="Verdana">
<?
// if multipart, display text sections
if(is_array($sections))
{
for($x=0; $x<sizeof($sections); $x++)
{
if(($sections[$x]["type"] == "text/plain" || $sections[$x]["type"] ==
"message/rfc822") && $sections[$x]["disposition"] != "attachment")
{
echo htmlspecialchars(stripslashes(trim(imap_fetchbody($inbox, $id,
$sections[$x]["pid"]))));
echo "<br>";
}
}
}
else
{
echo htmlspecialchars(stripslashes(trim(imap_body($inbox, $id))));
}
?>
</font></pre></td>
</tr>
<?
// if attachments exist
if (is_array($attachments))
{
?>
<tr>
<td valign=top><font face="Verdana" size="-1"><b>Attachments:
</b></font></td>
<td valign=top><font face="Verdana" size="-1"><ul>
<?
// display as list
for($x=0; $x<sizeof($attachments); $x++)
{
echo "<li><a href=download.php?id=$id&pid=" . $attachments[$x]["pid"] .
">" . $attachments[$x]["name"] . " (" . ceil($attachments[$x]["size"]/1024)
. " KB)</a>";
}
?>
</ul></font></td>
</tr>
<?
}
?>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" align="left" valign="top">
<?
if ($id > 1)
{
// display previous message link
echo "<a href=view.php?id=" . ($id-1) ."><font face=Verdana
size=-2>Previous message</font></a>";
}
?>
</td>
<td align="right" width="50%" valign="top">
<?
// display next message link
if ($id < $total)
{
echo "<a href=view.php?id=" . ($id+1) ."><font face=Verdana size=-2>Next
message</font></a>";
}
?>
</td>
</tr>
</table>
</body>
</html>
<?php
// clean up
imap_close($inbox);
?>
?>
ولكن مشكلتة انه يقوم بعملية الالتصال
قمت بتعديلة شوي من شان موضوع ال ID الخاص فلم يقبل
مررت للمتغير $inbox الرسالة كلها طبعا بدون ال $id فاكيد لم يقبلها
هذة هي مشكلتي فقط .
ارجو النظر
الكود الغير معدل :
كود PHP:
<?php
// view.php - display message
// includes
// session check
// check for required values
if (!$id)
{
header("Location: error.php?ec=4");
exit;
}
// open POP connection
$inbox = @imap_open ("{". $SESSION_MAIL_HOST . "/pop3:110}",
$SESSION_USER_NAME, $SESSION_USER_PASS) or header("Location:
error.php?ec=3");
?>
<html>
<head>
</head>
<body bgcolor="White">
<?
// get message headers and structure
$headers = imap_header($inbox, $id);
$structure = imap_fetchstructure($inbox, $id);
// if multipart, parse
if(sizeof($structure->parts) > 1)
{
$sections = parse($structure);
$attachments = get_attachments($sections);
}
?>
<table width="100%" border="0" cellspacing="3" cellpadding="5">
<!-- command buttons -->
<tr>
<td width="100%"> </td>
<td valign=top align=center><a href="compose.php"><img
src="images/compose.gif" width=50 height=50 alt="" border="0"><br><font
face="Verdana" size="-2">Compose</font></a></td>
<td valign=top align=center><a href="reply.php?id=<? echo $id; ?>"><img
src="images/reply.gif" width=50 height=50 alt="" border="0"><br><font
face="Verdana" size="-2">Reply</font></a></td>
<td valign=top align=center><a href="forward.php?id=<? echo $id; ?>"><img
src="images/forward.gif" width=50 height=50 alt="" border="0"><br><font
face="Verdana" size="-2">Forward</font></a></td>
<td valign=top align=center><a href="delete.php?dmsg[]=<? echo $id;
?>"><img src="images/delete.gif" width=50 height=50 alt=""
border="0"><br><font face="Verdana" size="-2">Delete</font></a></td>
<td valign=top align=center><a href="list.php"><img src="images/list.gif"
width=50 height=50 alt="" border="0"><br><font face="Verdana"
size="-2">Messages </font></a></td>
</tr>
</table>
<table border="0" cellspacing="1" cellpadding="5" width="100%">
<tr>
<td valign=top><font face="Verdana" size="-1"><b>From: </b></font></td>
<td valign=top width=100%><font face="Verdana" size="-1"><? echo
htmlspecialchars($headers->fromaddress);
?></font></td>
</tr>
<tr>
<td valign=top><font face="Verdana" size="-1"><b>To:</b></font></td>
<td valign=top><font face="Verdana" size="-1"><? echo
htmlspecialchars($headers->toaddress); ?>
</font>
</td>
</tr>
<?php
if($headers->ccaddress)
{
?>
<tr>
<td valign=top><font face="Verdana" size="-1"><b>Cc: </b></font></td>
<td valign=top><font face="Verdana" size="-1"><? echo
htmlspecialchars($headers->ccaddress); ?>
</tr>
<?
}
?>
<tr>
<td valign=top><font face="Verdana" size="-1"><b>Date: </b></font></td>
<td valign=top><font face="Verdana" size="-1"><? echo
$headers->Date;?></font></td>
</tr>
<tr>
<td valign=top><font face="Verdana" size="-1"><b>Subject: </b></font></td>
<td valign=top><font face="Verdana" size="-1">
<?
// correction for empty subject
if ($headers->Subject)
{
echo $headers->Subject;
}
else
{
echo "No subject";
}
?>
</font></td>
</tr>
<tr>
<td colspan=2 valign="TOP"><pre><font face="Verdana">
<?
// if multipart, display text sections
if(is_array($sections))
{
for($x=0; $x<sizeof($sections); $x++)
{
if(($sections[$x]["type"] == "text/plain" || $sections[$x]["type"] ==
"message/rfc822") && $sections[$x]["disposition"] != "attachment")
{
echo htmlspecialchars(stripslashes(trim(imap_fetchbody($inbox, $id,
$sections[$x]["pid"]))));
echo "<br>";
}
}
}
else
{
echo htmlspecialchars(stripslashes(trim(imap_body($inbox, $id))));
}
?>
</font></pre></td>
</tr>
<?
// if attachments exist
if (is_array($attachments))
{
?>
<tr>
<td valign=top><font face="Verdana" size="-1"><b>Attachments:
</b></font></td>
<td valign=top><font face="Verdana" size="-1"><ul>
<?
// display as list
for($x=0; $x<sizeof($attachments); $x++)
{
echo "<li><a href=download.php?id=$id&pid=" . $attachments[$x]["pid"] .
">" . $attachments[$x]["name"] . " (" . ceil($attachments[$x]["size"]/1024)
. " KB)</a>";
}
?>
</ul></font></td>
</tr>
<?
}
?>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" align="left" valign="top">
<?
if ($id > 1)
{
// display previous message link
echo "<a href=view.php?id=" . ($id-1) ."><font face=Verdana
size=-2>Previous message</font></a>";
}
?>
</td>
<td align="right" width="50%" valign="top">
<?
// display next message link
if ($id < $total)
{
echo "<a href=view.php?id=" . ($id+1) ."><font face=Verdana size=-2>Next
message</font></a>";
}
?>
</td>
</tr>
</table>
</body>
</html>
<?php
// clean up
imap_close($inbox);
?>