1 (edited by druvans 2005-06-21 16:02)

Topic: reading from POP3/IMAP

I was trying to read my mails from  POP3/IMAP mail box,  the script was able to open the mail box from my machine, but when I loaded it to website, it is not working

<?php
$mbox = imap_open("{host:143}", "mail id", "password");

echo "<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($mbox, "{host:143}", "*");

if ($folders == false) {
   echo "Call failed<br />\n";
} else {
   while (list ($key, $val) = each($folders)) {
       echo $val . "<br />\n";
   }
}

echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);

if ($headers == false) {
   echo "Call failed<br />\n";
} else {
   while (list ($key, $val) = each ($headers)) {
       echo $val . "<br />\n";

   }
}

imap_close($mbox);
?>

Re: reading from POP3/IMAP

i guess no imap functions on your server? what error do you get?

Re: reading from POP3/IMAP

it says call failed.
When I checked php info it shows IMAP c-Client Version     2000 and SSL Support     enabled.

Re: reading from POP3/IMAP

whats the actual error message? and what line does it give?

5 (edited by Bwongar.com 2005-06-21 18:04)

Re: reading from POP3/IMAP

Connor - he's using the actual method described on php.net. The error he described is after the condition "if ($folders == false)". He's not getting an actual folder list from the IMAP server.

Druvans - Are you sure that host you are attempting to connect to allows IMAP, and are you suer of the port?

Re: reading from POP3/IMAP

On further inspection you should be able to use imap_errors() to help find the problem. Put the following line of code near at the bottom and show us the results:

print_r(imap_errors());

Re: reading from POP3/IMAP

thanks Connor and Bwongar

Array ( [0] => Certificate failure for pendrell.textdrive.com: unable to get local issuer certificate: /C=US/O=pendrell.textdrive.com/OU=https://services.choicepoint.net/get.jsp?GT04768306/OU=See www.freessl.com/cps (c)04/OU=Domain Control Validated - StarterSSL(TM)/CN=pendrell.textdrive.com )

Re: reading from POP3/IMAP

Looks like an SSL issue. Talk with your host about the error reported.

Re: reading from POP3/IMAP

when I execute the script from my PHP editor, it works.  anyway I ll mail to textdrive tech support

Re: reading from POP3/IMAP

druvans wrote:

when I execute the script from my PHP editor, it works.  anyway I ll mail to textdrive tech support

Hm... Does it actually execute or just debug?