PHP Imap

Associate
Joined
30 Dec 2005
Posts
415
Ok so just been introduced to the PHP Imap functions and am looking forward to using it, but am not sure what the address should be.
The server i'm using is running cpanel, and when you wish to set up an email account for it, it should point to mail.yourdomain.com.

PHP:
//Ping POP3
if(imap_open ("{mail.localhost:110/imap}Inbox", "username", "password"))
{
   echo 'Connection success!';
}
else
{
   echo 'Connection failed';

Could someone explain the exact address I need to call upon instead of mail.localhost:110/imap as that returns this:

Warning: imap_open(): Couldn't open stream {mail.localhost:110/imap}Inbox in /home/etc..etc..
 
Or swap mail.localhost for localhost to avoid the dns lookup :).

Edit: And IMAP is port 143, 110 is POP3.
 
Cheers for the fast response.

Still the same problem though...
"{localhost:143}Inbox"
gives
Warning: imap_open(): Couldn't open stream {localhost:143}Inbox in /home/etc...

Am I still doing it wrong or is it time to call the hosting company to check imap is set up? It looks like it is else it wouldn't try to open the stream would it?
 
Hmm... imap should be running and listening on all interfaces in a standard cPanel configuration. Try this... open a command prompt in Windows and type

"telnet yoursite.com 143"

What happens?
 
Adz said:
Or swap mail.localhost for localhost to avoid the dns lookup :).

Edit: And IMAP is port 143, 110 is POP3.

I've never used IMAP before, but I presumed IMAP servers worked like web servers do, and have different inboxes depending on the domain - so mail.domain1.com and mail.domain2.com would be on the same server, on the same port, but the server would respond differently depending on the domain sent. I guess IMAP doesn't have the equivalent of a Host: header, though :o
 
robmiller said:
I've never used IMAP before, but I presumed IMAP servers worked like web servers do, and have different inboxes depending on the domain - so mail.domain1.com and mail.domain2.com would be on the same server, on the same port, but the server would respond differently depending on the domain sent. I guess IMAP doesn't have the equivalent of a Host: header, though :o

They do have different mailboxes but it is entirely login based.
 
If I do the telnet I get the following:
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THRE
AD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyr
ight 1998-2005 Double Precision, Inc. See COPYING for distribution information.

Rob, I originally thought it would need the mail. at the front, but i've never used IMAP before so I have no idea how it works etc atm... guess i've just gotta learn :p
 
Hmm IMAP is definitely running in that case however that's not the greeting output one would expect from cPanel's implementation. Perhaps your hosts are using their own installation (it might not actually be configured fully). In any case, it should still be listening on localhost but you could try swapping localhost for mail.yourdomain.com as per rob's suggestion ;).

Edit: php.net suggests appending /notls i.e localhost:143/imap/notls
 
Last edited:
If you have a home server and fancy an afternoon playing with Linux, install the MTA of your choice along with the IMAP server of your choice then install fetchmail and configure it to pull down your domain email as well as your gmail. You can then log into it via IMAP across your local network (very fast). Et voila, instant network mail storage, accessible from any machine on your LAN (and off of it if you like).

Even if your host did offer IMAP, you wouldn't want to use it across that kind of distance - IMAP is painful with that kind of latency :(.
 
Especially since my host is el-cheap Dreamhost, 5,000 miles and the Atlantic Ocean away :o

That sounds pretty cool, though, and moreso considering I've just acquired an old Athlon ~400. Care to recommend an IMAP server?
 
Courier :)

If you want to set up an all singing, all dancing mail server with no fuss, check out www.qmailrocks.org - it'll take you through installing qmail, vpopmail, courier, spamassassin, clamav and much much more.
 
Back
Top Bottom