Jump to content

imap_open() "couldn't open stream" with GMail, but works locally.


DonnieG

Recommended Posts

<?php

$mbox = imap_open("{imap.gmail.com:993/ssl/novalidate-cert}INBOX", "myemail@gmail.com", "PASSWORD");
 
$old_msg_numbers = imap_search($mbox, "");
 
echo "This should report the message numbers retrieved from GMail\r\n";
var_dump($old_msg_numbers);
echo "\r\nimap_errors:\r\n";
var_dump(imap_errors());
echo "\r\nimap_alerts:\r\n";
var_dump(imap_alerts());
 
imap_close($mbox);
 
phpinfo();
 
?>
 

When I run this locally on my Windows machine, with XAMPP and PHP, it runs and works properly. any time I give it to a hosting company, it doesn't run, instead it generates the PHP warning here: 

 

PHP Warning: imap_open() [<a href='function.imap-open'>function.imap-open</a>]: Couldn't open stream {imap.gmail.com:993/ssl/novalidate-cert}INBOX in /path-goes-here/test.php on line 3

 

I have used this on two different hosting providers, hostmonster.com and godaddy.com, they say they are not blocking port 993, which GMail requires.

 

Using Port settings defined by Google ( http://support.google.com/mail/bin/static.py?hl=en&ts=1668960&page=ts.cs&rd=1 ), and that shouldn't matter, because its working fine on my local machine.

 

What do?

Link to comment
Share on other sites

@DonnieG
 
I'm with Go Daddy and came across your post.
 
Is this script on a shared hosting or virtual/dedicated server environment? If your on a shared hosting account and are trying to get it to send emails from mail-forms etc you will want to use our SMTP relays available for your hosting account.
 
http://support.godaddy.com/help/article/345/what-is-smtp-relay
 
http://support.godaddy.com/help/article/951/what-email-or-relay-server-should-i-use-in-my-php-code
 
If your on a Virtual/Dedicated server and are still running into the issues please let me know. Feel free to reply or to send me a private message.

Link to comment
Share on other sites

  • 3 months later...
<?php

$mbox = imap_open("{imap.gmail.com:993/ssl/novalidate-cert}INBOX", "myemail@gmail.com", "PASSWORD");
 
$old_msg_numbers = imap_search($mbox, "");
 
echo "This should report the message numbers retrieved from GMail\r\n";
var_dump($old_msg_numbers);
echo "\r\nimap_errors:\r\n";
var_dump(imap_errors());
echo "\r\nimap_alerts:\r\n";
var_dump(imap_alerts());
 
imap_close($mbox);
 
phpinfo();
 
?>
 

When I run this locally on my Windows machine, with XAMPP and PHP, it runs and works properly. any time I give it to a hosting company, it doesn't run, instead it generates the PHP warning here: 

 

PHP Warning: imap_open() [<a href='function.imap-open'>function.imap-open</a>]: Couldn't open stream {imap.gmail.com:993/ssl/novalidate-cert}INBOX in /path-goes-here/test.php on line 3

 

I have used this on two different hosting providers, hostmonster.com and godaddy.com, they say they are not blocking port 993, which GMail requires.

 

Using Port settings defined by Google ( http://support.google.com/mail/bin/static.py?hl=en&ts=1668960&page=ts.cs&rd=1 ), and that shouldn't matter, because its working fine on my local machine.

What do?

 

 

Even this code not working locally :/, can you please let me know who can I execute it properly? I have enable php_imap and php_openssl in my wamp server php setting, I am using "wampserver2.2e-php5.3.13-httpd2.2.22-mysql5.5.24-32b"

Edited by krsitenmorey111
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.