imap function is not working for me with PHP
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@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);
You need to enable imap in your php.ini
.
I used the wamp menu to edit the php.ini. I enabled the php_imap.dll.
-> http://www.wampserver.com/phorum/read.php?2,23447,printview,page=1
I got the solution:
I am running Windows 7 64bit
environment with WAMP
server, it has two php.ini
files:
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
And it works now !
精彩评论