41 lines
1.2 KiB
PHP
41 lines
1.2 KiB
PHP
<?php
|
|
//autoload not use
|
|
require_once __DIR__."/Exceptions/ConnectionException.php";
|
|
require_once __DIR__."/Exceptions/InvalidParameterException.php";
|
|
require_once __DIR__."/DataPartInfo.php";
|
|
require_once __DIR__."/IncomingMailHeader.php";
|
|
require_once __DIR__."/IncomingMailAttachment.php";
|
|
require_once __DIR__."/IncomingMail.php";
|
|
require_once __DIR__."/Imap.php";
|
|
require_once __DIR__."/Mailbox.php";
|
|
|
|
$mailbox = new PhpImap\Mailbox(
|
|
"{imap.gmail.com:993/imap/ssl}INBOX",
|
|
'frody@imemo.co.kr', // Username for the before configured mailbox
|
|
'' // Password for the before configured username
|
|
);
|
|
|
|
$mailbox->setConnectionArgs(
|
|
CL_EXPUNGE // expunge deleted mails upon mailbox close
|
|
| OP_SECURE // don't do non-secure authentication
|
|
);
|
|
|
|
echo '<pre>';
|
|
try {
|
|
// Get all emails (messages)
|
|
// PHP.net imap_search criteria: http://php.net/manual/en/function.imap-search.php
|
|
print_r($mailbox);
|
|
$mailsIds = $mailbox->searchMailbox('ALL');
|
|
echo $mailsIds;
|
|
} catch(PhpImap\Exceptions\ConnectionException $ex) {
|
|
echo "IMAP connection failed: " . implode(",", $ex->getErrors('all'));
|
|
die();
|
|
}
|
|
|
|
// If $mailsIds is empty, no emails could be found
|
|
if(!$mailsIds) {
|
|
die('Mailbox is empty');
|
|
}
|
|
|
|
echo 111;
|