我使用php-imap-client從php-imap中獲得我的郵件,腳本沒有問題,但我想限制從服務器獲取的郵件數量。如何在php-imap上限制結果
這是腳本:
<?PHP
require_once "Imap.php";
$mailbox = 'imap-mail.outlook.com';
$username = '[email protected]';
$password = 'MYPASSWORD';
$encryption = 'ssl'; // or ssl or ''
// open connection
$imap = new Imap($mailbox, $username, $password, $encryption);
// stop on error
if($imap->isConnected()===false)
die($imap->getError());
// get all folders as array of strings
$folders = $imap->getFolders();
foreach($folders as $folder)
echo $folder;
// select folder Inbox
$imap->selectFolder('INBOX');
// count messages in current folder
$overallMessages = $imap->countMessages();
$unreadMessages = $imap->countUnreadMessages();
// fetch all messages in the current folder
$emails = $imap->getMessages($withbody = false);
var_dump($emails);
// add new folder for archive
$imap->addFolder('archive');
// move the first email to archive
$imap->moveMessage($emails[0]['id'], 'archive');
// delete second message
$imap->deleteMessage($emails[1]['id']);
我使用的腳本:https://github.com/SSilence/php-imap-client
我該怎麼辦呢?
你能分享樣本,如何從開始位置獲取消息。我有400封信。我這樣做:$ this-> imapService-> getMessages(200,400);我試圖從位置200到400的信件 – OPV