Jump to content


Photo

PHP and IMAP extension


  • Please log in to reply
1 reply to this topic

#1 waverider

waverider
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 10 June 2006 - 09:24 AM

Hello,
Having trouble logging on to hosting company's shared server using IMAP. The webmail program I am using in the root of my site won't log on and I can't log on with a testing script either. They insist the extensions are installed correctly as HORDE and Squirrelmail work OK.

PHP v 5.1.4 IMAP c-client version 2004

I have used the test script below loaded into the root of the domain and get the message:

Warning: imap_open() [function.imap-open]: Couldn't open stream {localhost:143/imap/notls}INBOX in /home/*****/public_html/imap_test2.php on line 10

Warning: imap_check(): supplied argument is not a valid imap resource in /home/*****/public_html/imap_test2.php on line 13
....
....
....

Is there something wrong with the script, am I unable to run it from the root of my domain, or is there something else such as the server not allowing this?

<HTML>
<HEAD>
<TITLE>imap_check</TITLE>
</HEAD>
<BODY>
<?
//check for new messages

$mailbox = imap_open("{localhost/imap:143}INBOX",
"myname@mydomain.com","mypassword");

// Check messages
$check = imap_check($mailbox);
print("<PRE>");
print("Date most recent message : " . $check->Date);
print("<BR>");
print("Connection type : " . $check->Driver);
print("<BR>");
print("Name of the mailbox : " . $check->Mailbox);
print("<BR>");
print("Number of messages : " . $check->Nmsgs);
print("<BR>");
print("Number of recent messages : " . $check->Recent);
print("<BR>");
print("</PRE>");

// show headers for messages

$index=1;

$header = imap_header($mailbox, $index);
print("<PRE>");
print("Header Date : " . $header->Date . "<BR>");
print("Header To : " . $header->to) . "<BR>";
print("Header From : " . $header->From . "<BR>");
print("Header cc : " . $header->cc . "<BR>");
print("Header ReplyTo : " . $header->ReplyTo . "<BR>");
print("Header Subject : " . $header->Subject . "<BR></PRE>");

print("<PRE>");
print(imap_body($mailbox,$index));
print("</PRE><HR>");

imap_close($mailbox);
?>

</BODY></HTML>

#2 waverider

waverider
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 10 June 2006 - 10:47 PM

Any ideas? Please
I have now added:

or die("can't connect: ".imap_last_error());

to the imap_open() part of the script and now get the message:


Warning: imap_open() [function.imap-open]: Couldn't open stream {localhost/imap:143}INBOX in /home/*****/public_html/imap_test2.php on line 9
can't connect: Can not authenticate to IMAP server: AUTHENTICATE LOGIN failed




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users