How do I use it?

<?php// Include the library firstrequire_once__DIR__.'/vendor/autoload.php';$path='path/to/mail.txt';$Parser=newPhpMimeMailParser\Parser();// There are four methods available to indicate which mime mail to parse.// You only need to use one of the following four:// 1. Specify a file path to the mime mail.$Parser->setPath($path); // 2. Specify a php file resource (stream) to the mime mail.$Parser->setStream(fopen($path, "r"));// 3. Specify the raw mime mail text.$Parser->setText(file_get_contents($path));// 4. Specify a stream to work with mail server$Parser->setStream(fopen("php://stdin", "r"));// Once we've indicated where to find the mail, we can parse out the data$to=$Parser->getHeader('to'); // "test" <test@example.com>, "test2" <test2@example.com>$addressesTo=$Parser->getAddresses('to'); //Return an array : [[test, test@example.com, false],[test2, test2@example.com, false]]$from=$Parser->getHeader('from'); // "test" <test@example.com>$addressesFrom=$Parser->getAddresses('from'); //Return an array : test, test@example.com, false$subject=$Parser->getHeader('subject');$text=$Parser->getMessageBody('text');$html=$Parser->getMessageBody('html');$htmlEmbedded=$Parser->getMessageBody('htmlEmbedded'); //HTML Body included data$stringHeaders=$Parser->getHeadersRaw(); // Get all headers as a string, no charset conversion$arrayHeaders=$Parser->getHeaders(); // Get all headers as an array, with charset conversion// Pass in a writeable path to save attachments$attach_dir='/path/to/save/attachments/'; // Be sure to include the trailing slash$include_inline=true; // Optional argument to include inline attachments (default: true)$Parser->saveAttachments($attach_dir [,$include_inline]);// Get an array of Attachment items from $Parser$attachments=$Parser->getAttachments([$include_inline]);// Loop through all the Attachmentsif (count($attachments) >0) {foreach ($attachmentsas$attachment) {echo'Filename : '.$attachment->getFilename().'<br />'; // logo.jpgecho'Filesize : '.filesize($attach_dir.$attachment->getFilename()).'<br />'; // 1000echo'Filetype : '.$attachment->getContentType().'<br />'; // image/jpegecho'MIME part string : '.$attachment->getMimePartStr().'<br />'; // (the whole MIME part of the attachment) }}?>

Next you need to forward emails to this script above. For that I'm using Postfix like a mail server, you need to configure /etc/postfix/master.cf

Add this line at the end of the file (specify myhook to send all emails to the script test.php)