Napisalem sobie skrypcik laczacy sie z serwerem ale przy ostatniej petli foreach wywala mi blad
Kod
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
$mailbox = "{imap.gmail.com:993/imap/ssl}INBOX";
$user = "nazwauzytkownika";
$pass = "haslo";
$mbox = imap_open ($mailbox, $user, $pass)
or die("can't connect: " . imap_last_error());
echo "<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($mbox, "{imap.gmail.com:993}", "*");
if ($folders == false) {
echo "Call failed<br />\n";
} else {
foreach ($folders as $val) {
echo $val . "<br />\n";
}
}
echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);
if ($headers == false) {
echo "Call failed<br />\n";
} else {
foreach ($headers as $val) {
echo $val . "<br />\n";
}
}
echo "<h1>Body of specified message</h1>\n";
$body = imap_body($mbox,1);
if ($body == false) {
echo "Call failed<br />\n";
} else {
foreach ($body as $val) {
echo $val . "<br />\n";
}
}
imap_close($mbox)
?>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
$mailbox = "{imap.gmail.com:993/imap/ssl}INBOX";
$user = "nazwauzytkownika";
$pass = "haslo";
$mbox = imap_open ($mailbox, $user, $pass)
or die("can't connect: " . imap_last_error());
echo "<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($mbox, "{imap.gmail.com:993}", "*");
if ($folders == false) {
echo "Call failed<br />\n";
} else {
foreach ($folders as $val) {
echo $val . "<br />\n";
}
}
echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);
if ($headers == false) {
echo "Call failed<br />\n";
} else {
foreach ($headers as $val) {
echo $val . "<br />\n";
}
}
echo "<h1>Body of specified message</h1>\n";
$body = imap_body($mbox,1);
if ($body == false) {
echo "Call failed<br />\n";
} else {
foreach ($body as $val) {
echo $val . "<br />\n";
}
}
imap_close($mbox)
?>
</body>
</html>
Wywala mi taki bład
Warning: Invalid argument supplied for foreach() in C:\Program Files\WebServ\httpd\PrackaMgr\index.php on line 46
Linia 46 to ta :
Kod
foreach ($body as $val) {
Jakies pomysly ?