Read Mail Error using imap_open

Posted on 2005-04-29
Last Modified: 2012-06-27
hi all,

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

the code as follows

$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

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:
Unit/CN=localhost.localdomain/Email=root@localhost.localdomain (errflg=2) in
Unknown on line 0

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

Question by:Loganathan Natarajan
    1 Comment

    Accepted Solution

    Have you tried using the /notls-flag?  Also I think the curly brackets should better be enclosed in single quotes '{'  etc.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now