gaza165 Posted June 9, 2009 Share Posted June 9, 2009 I need to display all emails from my server... Am a bit confued with what to put as the for loop.... <?php $mail = new GetMail("imap.gmail.com",$username, $password, "imap", ""); echo "<table border=1>"; echo "<tr><td><b>Sender</b></td><td><b>Subject</b></td><td><b>Date</b></td></tr>"; for($j=1; $j == 1; $j++) { $headers = array_reverse($mail->headers($j)); foreach ($headers as $uid=>$header) { //date of message $datemsg = $header->date; //subject $subjectmsg = $header->subject; //who its from $from = $header->from; //message text foreach ($mail->body($uid, FT_UID) as $i=>$part) { if ($part['MIMETYPE'] == "TEXT/PLAIN") { $body = $part['DATA']; } } ?> <tr> <td><b><a href="main.php?view=mail&uid=<? echo $uid; ?>"><? echo $from[0]->personal ?></a></b></td> <td><? echo $subjectmsg; ?></td> <td><? echo $datemsg; ?></td> </tr> <?php } } } ?> i get the error Warning: imap_fetchstructure() [function.imap-fetchstructure]: Bad message number in C:\XAMPP\htdocs\email\includes\emailclass.php on line 160 Link to comment https://forums.phpfreaks.com/topic/161516-need-help-with-looping-email/ Share on other sites More sharing options...
Sarutobi Posted June 9, 2009 Share Posted June 9, 2009 IDK, I am rather new at php coding but it seem to me that the for($j=1; $j == 1; $j++) { statement is wrong $j=1; $j==1 $j++ // wont do anything cause $j is already equal to 1 if your wondering what value to set to '1' then you need to edit your imap to get the number of new email and set it to that so that the for statement runs till it hits the nimber of new emails .... hoep that helps. Link to comment https://forums.phpfreaks.com/topic/161516-need-help-with-looping-email/#findComment-852414 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.