PHP code example of messaged / php-mime-mail-parser
1. Go to this page and download the library: Download messaged/php-mime-mail-parser 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/ */
messaged / php-mime-mail-parser example snippets
use MimeMailParser\Parser;
use MimeMailParser\Attachment;
$parser = new Parser();
$parser->setText(file_get_contents('/path/to/mail'));
$to = $parser->getHeader('to');
$delivered_to = $parser->getHeader('delivered-to');
$from = $parser->getHeader('from');
$subject = $parser->getHeader('subject');
$text = $parser->getMessageBody('text');
$html = $parser->getMessageBody('html');
$attachments = $parser->getAttachments();
// Write attachments to disk
foreach ($attachments as $attachment) {
$attachment->saveAttachment('/tmp');
}