Forum Moderators: coopster

Message Too Old, No Replies

IMAP functions

         

hermes

2:12 am on Jul 28, 2005 (gmt 0)

10+ Year Member



I have signed up with a new web host and want to use IMAP functions with them. They do support these. I have checked. They have provided webmail at url:

[webmail.mydomain.com...]

so I guessed that I should use this syntax in my php script:

imap_open("{webmail.mydomain.com:143 INBOX", "username", "password");

But it does not work. I receive this error message:

Warning: imap_open(): Couldn't open stream {webmail.mydomain.com:143}INBOX

Help! I have asked my host about this and from their reply I dont think they even know what IMAP functions are. So, I am really stuck. I have read about opening an IMAP stream and that there are different syntaxes for different software components and scenarios - how can I find out which one is appropriate for my set up, given that asking my host is out?

The webmail is horde webmail. The login url is below

[webmail.mydomain.com...]

I am on a virtual server. So, I have an IP - but it is a shared IP of course. My host provided me with 3 IPs - one for FTP access, one is just my private IP (behind a firewall), the other is a public IP (outside the firewall). I have to give my public IP to DNS.

hermes

2:19 am on Jul 28, 2005 (gmt 0)

10+ Year Member



Just tried it with:

webmail.example.com/horde:143

Didn't work:

Warning: imap_open(): Couldn't open stream {webmail.mydomain.com/horde:143}INBOX

[edited by: jatar_k at 2:22 am (utc) on July 28, 2005]
[edit reason] generalized url [/edit]

jatar_k

2:29 am on Jul 28, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I assume you have read through

[php.net...]
including the user comments

I am guessing the connect string is the problem

try this search [google.com] for some more examples
not sure haven't really used the imap functions

I hate horde

hermes

2:42 am on Jul 28, 2005 (gmt 0)

10+ Year Member



Just tried localhost. Didn't work:

Warning: imap_open(): Couldn't open stream {localhost:143}INBOX

Am really stuck.

hermes

3:07 am on Jul 28, 2005 (gmt 0)

10+ Year Member



Warning: imap_open(): Couldn't open stream {example.com:143}INBOX

[edited by: jatar_k at 2:30 pm (utc) on July 28, 2005]
[edit reason] generalized domain [/edit]

hermes

10:56 am on Jul 28, 2005 (gmt 0)

10+ Year Member



Anyone any ideas? I am still so stuck with this.

hermes

11:44 am on Jul 28, 2005 (gmt 0)

10+ Year Member



There are so many variants on this syntax. How do I know which one to use? Is there any diagnostic that I can do to find out? In normal circumstances I would just ask my host. But they dont want to know. I am using horde webmail - would this have a bearing on the appropriate syntax?

-------

Here I have cut and paste some info on the variation in this syntax:

// To connect to an IMAP server running on port 143 on the local
machine use:

$mbox = imap_open("{localhost:143}INBOX", "user_id", "password");

// To connect to a POP3 server on port 110 on the local server, use:
NOTE HERE A POP3 IS USED
$mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password");

// To connect to an SSL IMAP or POP3 server, add /ssl after the
protocol
// specification:
$mbox = imap_open ("{localhost:993/imap/ssl}INBOX", "user_id",
"password");

// To connect to an SSL IMAP or POP3 server with a self-signed
certificate,
// add /ssl/novalidate-cert after the protocol specification:
$mbox = imap_open ("{localhost:995/pop3/ssl/novalidate-cert}",
"user_id", "password");

// To connect to an NNTP server on port 119 on the local server, use:
$nntp = imap_open ("{localhost:119/nntp}comp.test", "", "");

Some IMAP servers have different forms for connection. For example, connection to Microsoft Exchange might require you to use "{mail.yourserver.com:143/imap}Inbox" and also provide the username as "<yourdomain>/<yourusername>".
If you are running your IMAP server using SSL, you may need to use "{mail.yourserver.com:993/ssl/novalidate-cert}INBOX".

jatar_k

3:35 pm on Jul 28, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



another thought

horde is php, you could look for it's connection code to see if that helps

MattyMoose

7:17 pm on Jul 28, 2005 (gmt 0)

10+ Year Member



You should do a test, first, to see if IMAP is accessible from your host (Even though they said it is...)

from the command-line on your host:

telnet mail.myhost.com 143

If you get something like this, you're OK:


Trying 12.34.56.78...
Connected to mail.myhot.com
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION STARTTLS] Courier-IMAP ready. Copyright 1998-2004 Double Precision, Inc. See COPYING for distribution information.

If you get a timeout, you're either being blocked by a firewall, or you've got the wrong hostname.

The problem, from what I can see, is that generally you're trying to connect to the webmail server -- they probably have their IMAP/mail server on another machine, or hostname.

hermes

7:21 pm on Jul 28, 2005 (gmt 0)

10+ Year Member



Got it sorted - thanks to all that posted. I really appreciate it. I was pretty worked up there. And it has been a hellish day. In the end I got this working:

$imap = imap_open("{localhost:143/notls}INBOX"

it is the /notls that I was missing. Not in the official documentation that this is essential - but it is needed for my system it would seem.