Created
March 8, 2018 00:08
-
-
Save thecrypticace/fe46f353d8f7bf6481b1396c8e1865d9 to your computer and use it in GitHub Desktop.
Sample IMAP Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Fetch\Server; | |
// https://github.com/tedious/Fetch | |
$server = new Server("outlook.office365.com", 993); | |
$server->setAuthentication("[email protected]", "mypassword"); | |
$server->setFlag("novalidate-cert"); | |
$server->setParam("DISABLE_AUTHENTICATOR", ["PLAIN"]); | |
foreach ($server->getMessages() as $message) { | |
$subject = $message->getSubject(); | |
$sender = $message->getAddresses("from"); | |
$textBody = $message->getMessageBody(false); | |
$htmlBody = $message->getMessageBody(true); | |
// Do something with the message | |
// … | |
// Delete it | |
$message->delete(); | |
} | |
// Remove deleted messages | |
$server->expunge(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment