PHP code example of forked / mailreader

1. Go to this page and download the library: Download forked/mailreader 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/ */

    

forked / mailreader example snippets




use Mail\MailParser;

$emailPath = "/var/mail/spool/dan/new/12323344323234234234";
$emailParser = new MailParser(file_get_contents($emailPath));

// You can use some predefined methods to retrieve headers...
$to = $emailParser->getTo();
$subject = $emailParser->getSubject();
$cc = $emailParser->getCc();
$from = $emailParser->getFrom();
$fromName = $emailParser->getFromName();
$fromEmail = $emailParser->getFromEmail();
$attachments = $emailParser->getAttachments();

$actualContent = $attachments[0]['content']

// ... or you can use the 'general purpose' method getHeader()
$emailDeliveredToHeader = $emailParser->getHeader('Delivered-To');

$emailBody = $emailParser->getPlain();
sh
cat tests/testfile | ./mailPipe.php
cmd
type tests\testfile | php mailPipe.php
sh
myhook unix - n n - - pipe              flags=F user=www-data argv=php -c /etc/php5/apache2/php.ini -f /var/www/mailPipe.php ${sender} ${size} ${recipient}