Link to home
Start Free TrialLog in
Avatar of Loganathan Natarajan
Loganathan NatarajanFlag for India

asked on

Read Mail Error using imap_open

hi all,

i have written code for access my inbox thourgh PHP, imap function available in PHP

the code as follows
---------------------------------------------------------------------------------------------
$MAIL_HOST="localhost";
$MAIL_USER="user";
$MAIL_PASS="pwd";

$inbox = imap_open ("{". $MAIL_HOST . ":143}INBOX", $MAIL_USER, $MAIL_PASS) or die("Error: unable to open mailbox");

$total = imap_num_msg($inbox);

for($x=$total; $x>0; $x--) {
      // get header and structure
      $headers = imap_header($inbox, $x);
      $structure = imap_fetchstructure($inbox, $x);
      htmlspecialchars($headers->fromaddress); // This is the FROM address
      foreach ($headers as $key => $value) {
            if (is_array($value)) $value = implode("\",\"", $value);
            echo $key . " = " . htmlspecialchars($value);
      }
}
// clean up
imap_close($inbox);
---------------------------------------------------------------------------------------------

When I execute above code, I get the below errors:

Warning: Couldn't open stream {localhost:143}INBOX in

/var/www/html/readinbox1.php on line 16 Error: unable to open mailbox

Warning: Certificate failure for localhost: self signed certificate:
/C=--/ST=SomeState/L=SomeCity/O=SomeOrganization/OU=SomeOrganizational
Unit/CN=localhost.localdomain/Email=root@localhost.localdomain (errflg=2) in
Unknown on line 0

How to solve this...Please help me....

logudotcom
ASKER CERTIFIED SOLUTION
Avatar of MBaas
MBaas
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial