You are hereBlogs / hutcho's blog / PHP imap_open can fail if you specify a mailbox in connection string.

PHP imap_open can fail if you specify a mailbox in connection string.


By hutcho - Posted on 15 January 2009

Recently our email parsing code written in PHP started to fail and the only indication of the problem was a PHP notice in the web server error_log that we hadn't encountered before.

"PHP Notice: Unknown: SECURITY PROBLEM: insecure server advertised AUTH=PLAIN"

A quick support call to our web host we found they had made a change to dovecot email system http://www.dovecot.org/

A bit of to and fro of them trying various settings in dovecot got us nowhere and eventually it was escalated to cPanel support. They quickly indicated that the problem could be resolved by editing the PHP connection string in imap_open to remove the INBOX string. So this got us back up and running by removing that from the connection string.

Old Code:

$mbox = imap_open ("{imap.example.org:143/notls}INBOX", $username, $password);

New Code which works but still throws the SECURITY PROBLEM message:

$mbox = imap_open ("{imap.example.org:143/notls}", $username, $password);

But we were still getting the SECURITY PROBLEM message in the web server error_log.

New Code which works and does not throw the SECURITY PROBLEM message:

$mbox = imap_open ("{imap.example.org:143/tls/novalidate-cert}", $username, $password);

Note that we have an SSL certificate installed on our site so this may not work if you do not have an SSL certificate, I haven't tried that.

References:
http://au.php.net/imap_open
http://www.washington.edu/imap/IMAP-FAQs/index.html
http://www.sugarcrm.com/forums/archive/index.php/t-24510.html

Hello,

I am starting a new website. What I will like to do is have one catch-all email address. I will like to register users and assign them email addresses. However these assigned email addresses will be stored in my MySql database and won't be actual accounts set up with my web host. But then emails can be sent to this individual addresses which will be caught by the catch-all address, then I can parse the emails and sort them out for each user according to the details on my database. This way I can have as many users as I want (irrespective of the number of mail addresses my host assigns to me), and I can design my own mail forms and add my special features. Firstly, is this the most efficient way I could achieve this or is there a better way?

My other question: from my google search I have observed imap_open fails to work with some web hosts due to security issues. In your experience and that of anyone else, which web host, which allows imap_open and other php functions I require to achieve my objective, is most suitable and dependable?

Hello,

I am starting a new website. What I will like to do is have one catch-all email address. I will like to register users and assign them email addresses. However these assigned email addresses will be stored in my MySql database and won't be actual accounts set up with my web host. But then emails can be sent to this individual addresses which will be caught by the catch-all address, then I can parse the emails and sort them out for each user according to the details on my database. This way I can have as many users as I want (irrespective of the number of mail addresses my host assigns to me), and I can design my own mail forms and add my special features. Firstly, is this the most efficient way I could achieve this or is there a better way?

My other question: from my google search I have observed imap_open fails to work with some web hosts due to security issues. In your experience and that of anyone else, which web host, which allows imap_open and other php functions I require to achieve my objective, is most suitable and dependable?

Mark
tolumark@gmail.com