Imap could not open stream on live server

1.4k views Asked by At

I am using imap_open to get email from gmail so its work on local server but when itry on live server it shows error.

Warning: imap_open(): Couldn't open stream {imap.gmail.com}INBOX

$server = "{imap.gmail.com/imap/ssl}";
$username = "[email protected]";
$password = "mypass";

$conn = imap_open ( $server , $username , $password );
$mailboxes = imap_list( $conn, $server, "*" );
echo "<pre>";
print_r($mailboxes);
2

There are 2 answers

4
Karthick Kumar On BEST ANSWER

try this for $server

   '{imap.gmail.com:995/imap/ssl}INBOX'
0
peter On
$server = "{imap.gmail.com:993/imap/ssl/novalidate-cert}INBOX";
$user   = "yourusername"; //do not include  @gmail.com nor googlemail.com
$passwd = "yourpassword";
$mbox = imap_open($server,$user,$passwd) or die("Could not open Mailbox - try again later!");