Answer the question
In order to leave comments, you need to log in
How to delete mail message from php server?
Good day, I use this to work with mail here
https://github.com/tedious/Fetch
Everything works fine but I can’t figure out how to delete a message from mail? in the meaning of erasing it physically and not moving it to the trash.
There is a method deleteMailBox but I can't figure out what exactly should be passed there.
Who worked with it prompt an example.
Answer the question
In order to leave comments, you need to log in
deleteMailBox deletes a completely specific mailbox (folder)
If you delete a specific message, then judging by the tests from the library, then something like this:
define('TESTING_SERVER_HOST', '127.0.0.1');
define('TEST_USER', 'testuser');
define('TEST_PASSWORD', 'applesauce');
function getMessage($id)
{
$server = new \Fetch\Server(TESTING_SERVER_HOST, 143);
$server->setAuthentication(TEST_USER, TEST_PASSWORD);
return new \Fetch\Message($id, $server);
}
//Ищем по Id
$message = getMessage(3);
//Помечаем как удаленное
$message->delete();
//Удаляем окончательно
$imapStream = $message->getImapBox()->getImapStream();
imap_expunge($imapStream);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question