Page 1 of 1

Making imap_headers readable so I can link to a message ID?

Posted: Fri Jul 25, 2008 11:21 am
by JAB Creations
I can't seem to figure out why when I try to display an individual message by the email's ID that I get a bad message number. Now below I create anchors to the message to read (the $_GET['read'] is the message id I get from the headers) but again it's telling me bad message numbers. I guess 1,2,3,4 aren't valid message numbers? This is all directly through IMAP, no DBs or anything. This one tiny thing is what I'm kind of stumped on and I'm doing pretty good with everything else right now (well I think at least heh). Help please!

List Page

Code: Select all

if (!isset($_GET['read']))
{
 $mail = 'user_at_domain.com'; /* obviously a working email is used but this code will appear on a client so I'm not going to give spam bots more targets to shot at */
 $pass = 'pass_here';
 $mbox = imap_open("{mail.jabcreations.com:143/notls}", $mail, $pass);
 $headers=imap_headers($mbox);
 for($x=1; $x < count($headers); $x++)
 {
  $idx=($x-1);
  echo '<div><a href="list.php?read='.$x.'">'.$headers[$idx].'</a></div>'."\n";
 }
 imap_close($mbox);
}
Individual Message Page

Code: Select all

else if (isset($_GET['read']))
{
 $mail = 'user_at_domain.com'; /* obviously a working email is used but this code will appear on a client so I'm not going to give spam bots more targets to shot at */
 $pass = 'pass_here';
 $mbox = imap_open("{mail.jabcreations.com:143/notls}", $mail, $pass);
 
 $id = $_GET['read'];
 $header=imap_header($mbox, $id);
/* The $header part is where I get the bad message ID from the $_GET['read']. */

Re: Making imap_headers readable so I can link to a message ID?

Posted: Fri Jul 25, 2008 12:53 pm
by JAB Creations
I didn't understand the flow of the second part...the first I comprehend though I'll still need to make it readable...at least a list that successfully links to each individual message is fine enough for now.

Code: Select all

$mbox = imap_open("{mail.jabcreations.com:143/notls}", $mail, $pass);
$id = $_GET['read'];
$header=imap_header($mbox, $id);
$message = imap_body($mbox, $id);
echo '<div>HEADER: '.imap_body($mbox,$id).'</div>';