0

I am having a problem connecting php code to an IMAP server.

So as it goes I have a VPS with Godaddy and I also have a shared hosting account that has the email address I want to connect to. I also have a local virtual machine running CentOS 6 with LAMP.

If I run my code on the Godaddy VPS, the imap connection works perfectly to the mailbox. As soon as I put the code on the local virtual machine it simply won't connect to the mail server:

Warning: imap_open(): Couldn't open stream {mailserverdomain.co.uk:143/imap/notls}INBOX in /var/www/html/getemail.php on line 25 Notice: Unknown: Can't connect to mailserverdomain.co.uk,143: Permission denied (errflg=2) in Unknown on line 0 

It is using exactly the same code, and exactly the same connection info that I use on the Godaddy VPS copy. So I don't understand why my local virtual machine won't connect to the mail server. I have iptables completely switched off on the local virtual machine.

I'm getting "permission denied", even though it works fine on the Godaddy VPS. Obviously i have php imap installed on my local vm because the functions work...they just fail to connect to the external mail server.

I get this error from imap_open

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

I don't get this running it from the Godaddy VPS, only from my internal virtual machine. It makes no sense!

And here is the php connection code which works fine on the VPS but not my VM:

imap_open("{" . $emailServer . ":" . $emailPort . "/imap/notls}INBOX",$emailUser,$emailPass)
Glen
  • 655
  • 3
  • 16
  • 31
  • This is not surprising - hosting companies will often deny incoming unauthenticated IMAP connections from external IPs. Easiest way to check is to `telnet` from both within the GoDaddy VPS and your own local VPS. There's probably nothing wrong with the code (why didn't you post your code by the way?) – sjagr Feb 04 '15 at 18:39
  • Can you telnet to that port `telnet mailserdomain.co.uk 143` from your virtual machine. If you can't, you know it's being blocked. – Robbert Feb 04 '15 at 18:41
  • Yes, as others indicate, you should get away from plaintext connections as soon as possible. 'Permission denied' is a weird error though, and probably doesn't indicate a remote problem. – Max Feb 04 '15 at 18:57
  • i can connect to the mailbox with outlook no problem and the virtual machine runs on a bridged network with its own lan ip...basically direct connection to the internet through my pc. i will try to telnet on the virtual mahine perhaps one of my firewalls it blocking it? – Glen Feb 04 '15 at 23:16
  • i didn't post the code because i didn't feel i needed to seeing as the code works fine on the vps, it can't be the code. Besides calling imap_open isn't a complicated task :) – Glen Feb 04 '15 at 23:18
  • Ok so i ran telnet to the mail server on port 143 from the virtual machine ssh, and it connected to the server no problem, and logged in! – Glen Feb 05 '15 at 09:25
  • imap_open is refusing to do an insecure login. Use TLS, or configure a more secure authentication type. – Max Feb 05 '15 at 16:36

0 Answers0