Jump to content

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
https://forums.phpfreaks.com/topic/260596-unread-messages-gmail/
Share on other sites

how about this? (You will need to change the <[email protected]> to an actual email address without the <> around it)

$mbox = imap_open ("{imap.gmail.com:993/imap/ssl/authuser=<[email protected]>}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.

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=<[email protected]>}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

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

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.

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.

When I use this code ....

 

$email = 'st********[email protected]';
$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]

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.