Jump to content

Recommended Posts

my added code a bit scary but works fine add what thorpe said then done........

 

 

With this PHP code snippet you can show an email overview and display emails. This example has been written for POP3 accounts. If you're using an IMAP account just replace /pop3 with /imap/notls

<?php
function show_mails($server, $account, $password)
{
$mailbox = imap_open("{".$server.":110/pop3}INBOX", $account, $password);
$mails = imap_fetch_overview($mailbox,"1:*", FT_UID); // This is fetching an overview of all emails

// Output as a table:
$return = '<table width="100%">
<tr>
<td><b>#</b></td>
<td><b>From</b></td>
<td><b>Date / Time</b></td>
<td><b>Subject</b></td>
</tr>';
$size = count($mails); // Number of messages
$cmsg = 0; // This is used to have a continously number
for($i=$size-1;$i>=0;$i--)
{
$cmsg++;
$value = $mails[$i];
$return .= '<tr><td>'.$cmsg.'</td><td>'.$value->from.'</td><td>'.$value->date.'</td><td><a href="'.$_SERVER['PHP_SELF'].'?id='.$value->msgno.'">'.$value->subject.'</a></td></tr>';
}
$return .= '</table>';
imap_close($mailbox);
return $return;
}

function show_mail($id, $server, $account, $password)
{
$mailbox = imap_open("{".$server.":110/pop3}INBOX", $account, $password);
$mail = imap_body($mailbox,$id, FT_UID);
// This is fetching the email..
$mail = htmlentities(stripslashes($mail));
/* stripslashes is stripping the slashes, htmlentities transforms all of the non-regular symbols to their equal html code expression. */
$return = '<pre>'.$mail.'</pre>';
imap_close($mailbox);
return $return;
}

if(isset($_GET['id']))
if(is_numeric($_GET['id']))
echo show_mail($_GET['id'], "YourServerAddress", "Account", "Password");
else
echo 'wrong parameter';
else
echo show_mails("YourServerAddress", "Account", "Password");
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.