I'm developing a web application that connects to an IMAP mailbox and fetches emails as part of it's functionality.
The application is PHP and I'm connecting like this:
public function connect()
{
/* connect to gmail */
$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = $this->username;
$password = $this->password;
/* try to connect */
$this->inbox = imap_open($hostname,$username,$password) or die('Cannot connect to Gmail: ' . imap_last_error());
}
Developing locally on my mac this was fine, I was able to connect and get emails. However now that I've put the app on my web hosts server I'm getting the following error:
Cannot connect to Gmail: Can't connect to gmail-imap.l.google.com,993: Connection timed out
After checking with my hosting provider they told me outgoing connections on port 993 are blocked. Is there anyway around this? Otherwise I need to upgrade to a dedicated server :S
You will need to upgrade, or ask your host if they can open up that port.
You actually gave the answer yourself - The port is 993, and afaik there is no way around it.
There's no way around the port block. Instead of upgrading to a dedicated server you could just move to a hosting provider that doesn't block the port or you could see if POP3, preferable over SSL, is an option. No less secure and even easier to code.