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", "[email protected]", "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?

@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.

  • 3 months later...
<?php

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.