Incoming mail with PHP Mime Mail Parser
I’ve just added the ability to parse mime mail from standard input into PHP Mime Mail Parser. This allows you to receive and parse email in PHP efficiently and effortlessly.Â
To pipe email to PHP, follow one of these articles:
Evolt - Incoming Mail and PHP
DevPapers - Incoming Mail and PHP
DevArticles - Incoming Mail and PHP
Then for your PHP code, get the PHP Mime Mail Parser, and use:
<?php
// include the mime-mail-parser class
require_once('MimeMailParser.class.php');
// instantiate
$Parser = new MimeMailParser();
// read the email from stdin
$Parser->setStream(STDIN);
// get the email parts
$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();
?>