1

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?

esqew
  • 42,425
  • 27
  • 92
  • 132
John Skoumbourdis
  • 3,041
  • 28
  • 34
  • It will be relevant that you're using MAMP, as the imap extension isn't even available in Apple's PHP install on Mavericks. If, on the command line, you try `telnet XXX.co.uk 993`, does it connect? – Matt Gibson Aug 11 '14 at 14:09
  • It seems that it does connect. I am getting: * OK The Microsoft Exchange IMAP4 service is ready. – John Skoumbourdis Aug 11 '14 at 14:29
  • Well, that's a start at diagnosis, at least. Your Mac is fine and its networking is able to see your server and connect on port 993. That narrows the problem down to MAMP, I'd say, but I'm afraid I've never used MAMP with imap. Hopefully someone else can help. I've tagged your post with "mamp", which might attract the right kind of people. – Matt Gibson Aug 11 '14 at 14:33
  • Thanks for the help. At least now I am investigating more to the MAMP problem. Hopefully I will find the answer and I will post it here so I may help other people as well. Thanks for taking the time and answer. – John Skoumbourdis Aug 11 '14 at 14:36
  • 1
    If you're getting a welcome banner when telneting to port 993, something is wrong, since 993 is the SSL port (or are you using an ssl enabled version of telnet?) – Max Aug 11 '14 at 17:42
  • @Max Interesting point; I'd missed the fact that it'd come back with plain text. I don't think the telnet client on OS X is SSL-aware; mine certainly doesn't seem to be... – Matt Gibson Aug 11 '14 at 22:26

1 Answers1

0

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.

John Skoumbourdis
  • 3,041
  • 28
  • 34