Forum Moderators: coopster
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
AAAAAARRRRRGGGGGGHHHHHHimap.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]
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.