Forum Moderators: coopster

Message Too Old, No Replies

Need help with IMAP email checker code!

My imap_open works at random times, is it a code thing or a server thing?

         

thesoundguy

6:29 am on Aug 22, 2003 (gmt 0)

10+ Year Member



I have a personal start page that has a bunch of links, rss feeds, and an email checker. This email checker basically displays whether I have new email and how many new messages.
The code I have researched and created works, but at random times. For the most part it works in the daytime, but it has been down in the daytime a few times. It is almost always down in the evening, but I have seen it work in the evening. I have experiemented with having email and without email in my inbox, for troubleshooting and no luck. I have tried several different browsers (IE,NS,Mozilla,Opera), and most just load nothing. IE loads the DNS error : cannot find server.
I have researched and tried what seems to be everything, but no luck. I have tried all the ports with all the /notls or /ssl and such tags. I know my web host service has IMAP provided.
Since this has been a random thing, could this be a server issue, and how would I bring it about to my hosting server?

The code : <snip>added below
My Web Host : Imhosted
PHP Ver : 4.3.2
Apache : 1.3.27
OS : Red Hat Linux

Has anyone else experienced anything similar to this, or know how to solve this? Any help would be greatly appreciative!

Thanks in advance!



code added from url by jatark
$tsgmbox = imap_open("{mail.site.com:143}", "**USERNAME**", "**PASSWORD**");

if ($tsgmbox === false)
die ("Can't connect: " . imap_last_error() ."\n");
else
{
$check = imap_mailboxmsginfo($tsgmbox);
if($check->Unread!= 0)
{
$emailoutput = "<a href=\"http://webmail.site.com/\"><img src=\"img/logo/home_emailyes.gif\" width=\"50\" height=\"35\" border=\"0\" alt=\"\" /></a><br />";
if ($check->Unread == 1)
$emailtotal = "<b>{$check->Unread}</b> &nbsp; <font size=\"2\">New Message</font>";
else
$emailtotal = "<b>{$check->Unread}</b> &nbsp; <font size=\"2\">New Messages</font>";
}
else
$emailoutput = "<a href=\"http://webmail.site.com/\"><img src=\"img/logo/home_emailno.gif\" width=\"50\" height=\"35\" border=\"0\" alt=\"\" /></a><br />";
imap_close($tsgmbox);
}

[edited by: jatar_k at 4:47 pm (utc) on Aug. 22, 2003]
[edit reason] no urls thanks, code was short so I added it [/edit]

Dolemite

2:14 am on Aug 23, 2003 (gmt 0)

10+ Year Member



I had the same problems with imap_open(). It would work at times, then not work for hours at a time. I came to the conclusion that it was just a very buggy function.

I ended up using a POP3 PEAR class [pear.php.net]. Note that it also needs the Net_Socket class.

It was a little inconvient compared to a predefined function, but once you get it going it works like a champ.

thesoundguy

1:16 pm on Aug 24, 2003 (gmt 0)

10+ Year Member



Dolemite, thanks for the info and link. I will check it out and try to get it implemented into my site. I was also informed by other people that IMAP has problems....
It is good to know that other people have this same problem, and it is not just problems with my code writing.

Dolemite

9:55 pm on Aug 24, 2003 (gmt 0)

10+ Year Member



> It is good to know that other people have this same problem, and it is not just problems with my code writing.

No kidding! I was going nuts with imap_open...I was thinking it was the server's fault but I couldn't convince my host of that. ;)