Jump to content

Unread Messages Gmail


smarcus3

Recommended Posts

I cant get this to work and I found a host with imap-ssl

 

here is my code though i've been messing around with it. It cant get the imap_open to work.

 

$mbox = imap_open ("{imap.gmail.com:993/imap/ssl/novalidate-cert/norsh}Inbox", 
"username", "password", OP_READONLY) 
or die("can't connect: " . imap_last_error());

$check = imap_mailboxmsginfo($mbox); 

echo $check->Unread; 
/

 

Please please help.

 

Thanks

Link to comment
Share on other sites

how about this? (You will need to change the <user_email@gmail.com> to an actual email address without the <> around it)

$mbox = imap_open ("{imap.gmail.com:993/imap/ssl/authuser=<user_email@gmail.com>}INBOX", "username","password", OP_READONLY) or die ("can't connect: " . imap_last_error());

 

your /novalidate-cert/norsh switches are for self signed servers, I'm pretty sure google has an authorised certificate or 10 so this isn't needed.

Link to comment
Share on other sites

When I use your code I get this error

 

Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl/authuser=<steven.g.marcus@gmail.com>}INBOX in /home/u332547992/public_html/default.php on line 45
can't connect: Can't connect to gmail-imap.l.google.com,993: Connection timed out

Link to comment
Share on other sites

Are you sure your host allows outgoing connections? Try something simple to test it like:

echo file_get_contents("http://google.com");

having read this http://support.google.com/mail/bin/answer.py?hl=en&answer=78799 and successfully connecting myself as I said in my last post - yeah, we're sure  :P

Did you try that from the same host as the OP, http://powrhost.com ? It's a free host and an "unlimited" one at that, so I don't have much faith in them allowing (or maybe not having the capacity to support) outgoing connections to other servers.

 

EDIT: to clarify, the error "Connection timed out" doesn't mean he got the login method wrong or anything. It simply means the PHP script tried to connect to that port but after however many second seconds gave up. I mean connect in the most raw form, just like opening a telnet session to port 993 on imap.gmail.com. If you were to do that, you immediately get:

# telnet imap.gmail.com 993
Trying 209.85.225.108...
Connected to gmail-imap.l.google.com.
Escape character is '^]'.

But this PHP script couldn't even get that far, so it seems it's something to do with the host.

Link to comment
Share on other sites

So not all outgoing connections are blocked, but they probably blocked connections to mail-related ports to prevent spam from being sent using their servers. I just tried it myself using a script I know that works. Sorry, but you'll have to find another host.

Link to comment
Share on other sites

I am now using 000webhosting which after talking to their IT they stated they support IMAP_OPEN but I still get the time out error.

 

I know this has already been talked about on other threads, but do you know of a free host which does allow this. I have tried many now.

Link to comment
Share on other sites

$email = 'youremail@gmail.com';
$pass  = 'yourpassword';
$inbox = imap_open('{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX', $email, $pass, NULL, 1) or die('Cannot connect to Gmail');

Link to comment
Share on other sites

$email = 'youremail@gmail.com';
$pass  = 'yourpassword';
$inbox = imap_open('{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX', $email, $pass, NULL, 1) or die('Cannot connect to Gmail');

 

That code doesn't work either :( It still times out.

Link to comment
Share on other sites

When I use this code ....

 

$email = 'st********us@gmail.com';
$pass  = '********';
$inbox = imap_open('{imap.gmail.com:993/imap/ssl}INBOX', $email, $pass, NULL, 1) or die('Cannot connect to Gmail');
[/Code]

 

I get this error now

 

[Code]Warning: imap_open() [function.imap-open]: Couldn't open stream {imap.gmail.com:993/imap/ssl}INBOX in /home/a6807236/public_html/default.php on line 56
Cannot connect to Gmail[/Code]

Link to comment
Share on other sites

Andy-H, go make an account at powrhost.com and see for yourself. They have port 993 blocked. I ran this and got a timeout:

<?php

error_reporting(-1);
fsockopen("imap.gmail.com", 993, $errorno, $errstr);
echo "$errorno $errstr";

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.