我尝试使用PHP访问我的Gmail帐户,但第2行收到错误消息。在Gmail中启用了IMAP,而未启用POP。
$mbox = imap_open("{imap.gmail.com:993/ssl}", "email@gmail.com", "password");
echo "<h1>Mailboxes</h1>\n";
$folders = imap_listmailbox($mbox, "{imap.gmail.com:993}", "*");
if ($folders == false) {
echo "Call failed<br />\n";
}
else {
foreach ($folders as $val) {
echo $val . "<br />\n";
}
}
echo "<h1>Headers in INBOX</h1>\n";
$headers = imap_headers($mbox);
if ($headers == false) {
echo "Call failed<br />\n";
}
else {
foreach ($headers as $val) {
echo $val . "<br />\n";
}
}
imap_close($mbox);
答案 0 :(得分:2)
您需要在php.ini
中启用imap。
我使用wamp菜单编辑php.ini。我启用了php_imap.dll。
- &GT; http://www.wampserver.com/phorum/read.php?2,23447,printview,page=1
答案 1 :(得分:0)
我得到了解决方案:
我正在使用Windows 7 64bit
服务器运行WAMP
环境,它有两个php.ini
个文件:
1] C:\wamp\bin\apache\apache2.2.22\bin
Enable php_imap.dll extension by removing ; at beginning of string
2] C:\wamp\bin\php\php5.3.13
Enable php_imap.dll extension by removing ; at beginning of string
它现在有效!