Mac OS X Mavericks: PHP error “imap_open() [functi

2019-08-12 03:51发布

问题:

I have an issue with imap_open function. It seems that my connection doesn't work on Mac OS X and I don't know why. If I try it on Windows (I am using WAMP), it works as expected without any issues. If I try the exact same code on Mac OS X Mavericks, it seems that I have the following error:

Warning: imap_open() [function.imap-open]: Couldn't open 
stream {XXX.co.uk:993/imap/ssl}INBOX in XXX.php on line XXX

The code is a simple connection with imap_open, you can see my code below:

$host = 'XXX.co.uk:993/imap/ssl';
$username = 'XXX';
$password = 'XXX';

$mailbox = '{'.$host.'}INBOX';
imap_open($mailbox , $username , $password);

If that matters, for Mac OS X Mavericks I am using MAMP.

I don't have a clue of why this is happening. Maybe a port blocking from Mac OS X? If this is the problem, can you please help me to solve this issue? How can I for example enable the 993 port for PHP and Mac OS X?

回答1:

Finally, I've found a solution for my problem.

I really couldn't found why this is happening and as a last resort I did install a Virtual Machine through Vagrant. I know that this maybe doesn't help to understand where the problem is but at least it may solve the problem of someone else. I realized that it was much faster to install a Vagrant rather than searching of why this is happening. An online wizard at Puphpet website with choosing the IMAP as an extension helped me to solve my problem. I hope this can help others as well with the same issue as mine.

I did try several things, like install PHP through CLI by recompiling it with imap and some other stuff without using MAMP and it didn't work for me.