Jump to content

PHP and IMAP extension


waverider

Recommended Posts

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",
"[email protected]","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>
Link to comment
https://forums.phpfreaks.com/topic/11644-php-and-imap-extension/
Share on other sites

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
Link to comment
https://forums.phpfreaks.com/topic/11644-php-and-imap-extension/#findComment-44146
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.