RE: [PEAR-DEV] Imap Backend Propsal

From: Date: Fri, 13 Feb 2004 07:21:44 +0000
Subject: RE: [PEAR-DEV] Imap Backend Propsal
Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-25640@lists.php.net to get a copy of this message
>Well, but wouldn't notls being the default make more sense? Also imap:// and >imaps:// are quite commonly used - so I'd suggest to just add "novalidate-cert" >as a possible option (anchor) but use imap / imaps to determine if ssl should >be used. I did that for notls and novalidate-cert on the anchor. But honestly I'm not sure! The docs for imap_open don't show notls as the default, but apparently *several* people have commented there that it is something that is commonly required. The problem that I see with setting it to be notls by default, is I can't see a way to easily exlude it in those cases where it wouldn't or shouldn't be added. >Well, it's not "the same". Having e.g. a look in your browser, into Thunderbird >or so shows that there are different types of SSL/TLS. E.g. Internet Explorer >(no flames please ;-)) has SSL 2.0, SSL 3.0 and TLS 1.0 as options. However, >most of the time today SSL and TLS are mentioned together - that's right! My URI has *just* ssl being specified in the argument if the 's' is added to the protocol (based on docs for imap_open), my question is, is that going to be a problem cause I don't want the program to *say* 'ssl' when the user means 'tls'. At this point it can be easily corrected by not specifing 's' on the protocol and adding that or anything extra to the path via the anchor. Here is the updated code: If the specification is: * For IMAP: imap://user:pass@mail.example.com:143/INBOX * * For IMAP SSL: imaps://user:pass@example.com:993/INBOX * * For POP3: pop3://user:pass@mail.example.com:110/INBOX * * For POP3 SSL: pop3s://user:pass@mail.example.com:993:/INBOX * * For NNTP: nntp://user:pass@mail.example.com:119/comp.test And the imap_open acceptable argument is: * For IMAP: {localhost:143}INBOX * * For IMAP SSL: {localhost:993/imap/ssl}INBOX * * For POP3: {localhost:110/pop3}INBOX * * For POP3 SSL: {localhost:993/pop3/ssl}INBOX * * For NNTP: {localhost:119/nntp}comp.test Then this is the solution I came up with: //snip $url =& new Net_URL($connect); $connect = '{'.$url->host; if (!empty($url->port)) { $connect .= ':'.$url->port; } $connect .= ('s' == (substr($url->protocol, -1)))? '/'.substr($url->protocol, 0, 4).'/ssl' : '/'.$url->protocol; if (!empty($url->anchor)) { $connect .= '/'.$url->anchor; } $connect .= '}'; // Trim off the leading slash '/' if (!empty($url->path)) { $connect .= substr($url->path, 1, (strlen($url->path) - 1)); } //snip Best Regards, Rich

« previous php.pear.dev (#25640) next »