imap 函数不适用于 PHP
我尝试使用 PHP 访问我的 Gmail 帐户,但在第 2 行收到错误消息。Gmail 中启用了 IMAP,但未启用 POP。
$mbox = imap_open("{imap.gmail.com:993/ssl}", "[email protected]", "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);
I try to access my gmail account with PHP, but I get an error message in line 2. IMAP is enabled in Gmail, while POP is not enabled.
$mbox = imap_open("{imap.gmail.com:993/ssl}", "[email protected]", "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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在
php.ini
中启用 imap。-> http://www.wampserver.com/phorum/read .php?2,23447,printview,page=1
You need to enable imap in your
php.ini
.-> http://www.wampserver.com/phorum/read.php?2,23447,printview,page=1
我得到了解决方案:
我正在使用
WAMP
服务器运行Windows 7 64bit
环境,它有两个php.ini
文件:现在可以使用了!
I got the solution:
I am running
Windows 7 64bit
environment withWAMP
server, it has twophp.ini
files:And it works now !