Forum Moderators: coopster

Message Too Old, No Replies

Difficulties with IMAP

         

nrobidoux

8:33 am on Sep 15, 2009 (gmt 0)

10+ Year Member



Due to some happenings with me missing an important email over the weekend I decided to write an email client with a few bells and whistles so that wouldn't happen in the future but right away I already have run into trouble.

For once I'm trying to use existing libraries (curl, imap, etc.) instead of this monolithic function I wrote a while back to handle http requests. I actually wanted to use IMAP instead of doing a bunch of HTTP requests and parsing the output to meet my needs.... cause if hotmail or any of the other email providers I use change the page the code needs retweaking and I hate that.

I'm having difficulty at the most basic of steps... connecting. I believe my code is ok...... is it?


<?php
$server = "imap.example.com:993";
$user = "n********.email@example.com";
$pass = "********";

if(false === ($conn = imap_open("\{$server/imap/ssl}INBOX", $user, $pass)))
echo "AAAAAARRRRRGGGGGGHHHHHH";

echo "<br><pre>$server\n$user\n$pass\n";
print_r(imap_alerts());
echo "\n";
print_r(imap_errors());
?>

The result I get is:


Warning: imap_open(): Couldn't open stream {imap.example.com:993/imap/ssl}INBOX in d:\website\mymail\index.php on line 19
AAAAAARRRRRGGGGGGHHHHHH

imap.example.com:993
n*********.email@example.com
********

Array
(
[0] => Can't open mailbox {imap.example.com:993/imap/ssl}INBOX: invalid remote specification
)

This was executed off my laptop.... off my hosting account the webpage that has this code "loads forever." Unfortunately I don't see how it's any different then what I saw on webpages as "working" code.

Where have I strayed? Behind the *'s is of course my real name and password. And these are the settings in the back of GMail.... I'm fairly sure.

Thanks

[edited by: eelixduppy at 12:09 pm (utc) on Sep. 15, 2009]
[edit reason] specifics [/edit]

jatar_k

5:06 pm on Sep 15, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



if it is loading forever then I would shorten the script and figure out what is hanging

if the imap_open function is hanging then maybe look if the port is open

if it is hotmail then they recently shut down access via outlook express so maybe this is related

nrobidoux

10:01 pm on Sep 15, 2009 (gmt 0)

10+ Year Member



The settings I have are for gmail and the code snippet above is the entire script at this point. I guess I'll have to reinvent the wheel :/

Adding a imap_close() right after still doesn't stop it from loading forever.

Using the following code outputs "SUCCESS":


if(false === ($sock = fsockopen('tcp://'.$server,995,$errno,$errstr)))
echo "<br>$errno - $errstr";
else {
echo "SUCCESS";
fclose($sock);
}

I changed $server so it did not have the port anymore. It's nowe in a separate variable.