Imap无法在实时服务器上打开流

时间:2014-01-17 12:17:21

标签: php gmail imap gmail-imap gmail-pop

我正在使用imap_open从gmail获取电子邮件,因此它在本地服务器上工作,但是当它在实时服务器上显示时会显示错误。

  

警告:imap_open():无法打开流{imap.gmail.com} INBOX

$server = "{imap.gmail.com/imap/ssl}";
$username = "mymail@gmail.com";
$password = "mypass";

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

2 个答案:

答案 0 :(得分:1)

试试$ server

   '{imap.gmail.com:995/imap/ssl}INBOX'

答案 1 :(得分:1)

$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!");