PHP code example of suffi / mail-reader

1. Go to this page and download the library: Download suffi/mail-reader library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

suffi / mail-reader example snippets



$conn = new \suffi\MailReader\Connection();

$conn->login = '***@xxx.ru';
$conn->password = '******';
$conn->server = 'ssl://outlook.office365.com';
$conn->port = '995';

$conn->connect();

$reader = new \suffi\MailReader\Reader($conn);

$message = $reader->getMessage(1273);

$message->getBody(); //Текст
 
$message->getHeader('date'); //Заголовки 
$message->getHeader('message-id'); //Заголовки 
$message->getHeader('subject'); //Заголовки 

/** Обход писем за последний день */
foreach ($reader->getMessages() as $message) {
    $curentDate = new DateTime();
    $date = new DateTime($message->getHeader('date'));

    if ($date->diff($curentDate)->d > 0) {
        break;
    }

    $message->getHeader('subject');    

}