+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

Thread: Problems accessing Gmail with PHP IMAP

  1. #1
    Join Date
    Jan 2008
    Posts
    3

    Default Problems accessing Gmail with PHP IMAP

    Hi Guys,

    I am attempting to access my Gmail account using PHP on my bluehost account and I keep getting the following error:

    Connection failed to gmail-imap.l.google.com,993: Connection timed out

    The code I'm using is:


    <?php

    $server = "imap.gmail.com";
    $user = "user@gmail.com";
    $pass = "pass";
    $conn = @imap_open("\{$server:993/imap/ssl}INBOX", $user, $pass)
    or die("Connection to server failed: ". imap_last_error());

    ?>


    I have tried a couple other flags in combination with /ssl e.g. /notls /novalidate-cert

    Any one succesfully tried this?

    I have checked that the phpinfo() has imap and ssl enabled.
    I have also checked that the port number and host name is correct. I have also tried imap.googlemail.com too.

    Thanks heaps,
    Adrian

  2. #2
    Join Date
    Feb 2006
    Location
    Florida, USA
    Posts
    1,349

    Default

    I believe you need a dedicated IP to make outbound connections on ports like that.

  3. #3
    Join Date
    Jan 2008
    Posts
    3

    Default

    ok, can any one confirm this?

    i've also previously checked that imap is enabled in my gmail account and it works from my thunderbird app on my local pc.
    Last edited by adrian.gab; 01-17-2008 at 11:42 PM.

  4. #4
    Join Date
    Feb 2006
    Location
    Florida, USA
    Posts
    1,349

    Default

    Well here's a pretty simple test.

    PHP Code:
    <?php
    $fp 
    = @fsockopen("imap.gmail.com"993$errno$errstr5);
    if(
    $fp) echo "success";
    else echo 
    "failure: ".$errstr;
    ?>
    Times out on my account. Succeeds on my computer. I can infer from this a few different conclusions, but the most likely is that the port is blocked.

  5. #5
    Join Date
    Jun 2008
    Posts
    1

    Thumbs up

    Basil Well here's a pretty simple test.

    PHP Code:
    <?php
    $fp = @fsockopen("imap.gmail.com", 993, $errno, $errstr, 5);
    if($fp) echo "success";
    else echo "failure: ".$errstr;
    ?>

    well first of all i know that i am posting after months of the last post but i just saw it while surfing net.
    The Gmail server requires secure connection (SSL) ,thus one(the main one) line of code above needs to be changed to :

    Instead of :

    $fp = @fsockopen("imap.gmail.com", 993, $errno, $errstr, 5);

    We should use :

    $fp = @fsockopen("ssl://imap.gmail.com", 993, $errno, $errstr, 5);

    Cheers!!!

  6. #6
    Join Date
    Apr 2008
    Posts
    407

    Default

    Basil is correct. You need a dedicated IP at $30/year to make outbound connections.

  7. #7
    Join Date
    Jan 2008
    Posts
    3

    Default

    Quote Originally Posted by Eriksrocks View Post
    Basil is correct. You need a dedicated IP at $30/year to make outbound connections.
    i had a very long winded online chat with a rude staff member from bluehost. after a long chat he finally divulged that even if you pay for a ip to make outbound connections you can't make outbound connections under port 1000. even though right at the start of the conversation i wanted to make an outbound IMAP connection to Gmail on port 993.

    now what on earth is the point of that!?! all the important ports are under 1000, plus this means bluehost customers can't access their gmail via imap.

    can another person from bluehost confirm this is true?

  8. #8
    Join Date
    Feb 2006
    Location
    Somewhere where I don't know where I am
    Posts
    2,155

    Default

    Quote Originally Posted by adrian.gab View Post
    can another person from bluehost confirm this is true?
    Since this is a user to user forum, you won't get any confirmation from bluehost here...


    I can use PHPMailer or Swiftmailer to make connections to Gmail and sent email and I have a dedicated IP
    Sign Up Now!
    Unlimited Storage, Unlimited Transfer, Host Unlimited domain names, 1 Free Domain Name
    BlueHost Features | BlueHost Help Desk | Become a BlueHost Affiliate | BlueHost CEO Blog
    (888) 401-4678 | Create a support ticket

  9. #9
    Join Date
    Apr 2008
    Posts
    407

    Default

    I highly doubt they dissallow ports under 1000.

  10. #10
    Join Date
    Feb 2007
    Location
    http://www.bluehostreview.org
    Posts
    1,104

    Default

    shared hosting does have a lot of restriction...
    thats when we need to find vps/dedicated-server that allow firewall customization for port :P
    Charles Gan
    Bluehost Reviews : Bluehost reviews hosted at bluehost
    Bluehost Speed Test : bluehost hosting speed Test!
    Bluehost Uptime : Bluehost uptime monthly reports

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts