note 100558 added to book.mailparse

From: Date: Sat, 23 Oct 2010 01:27:39 +0000
Subject: note 100558 added to book.mailparse
Groups: php.notes 
Request: Send a blank email to php-notes+get-173392@lists.php.net to get a copy of this message
I've put together an open source mail parser class using mailpase functions. http://code.google.com/p/php-mime-mail-parser/ This should make it more straight forward to parse the email. Example usage: <?php // mail parser class require_once('MimeMailParser.class.php'); $path = 'path/to/mail.txt'; $Parser = new MimeMailParser(); $Parser->setPath($path); $to = $Parser->getHeader('to'); $from = $Parser->getHeader('from'); $subject = $Parser->getHeader('subject'); $text = $Parser->getMessageBody('text'); $html = $Parser->getMessageBody('html'); $attachments = $Parser->getAttachments(); // saving attachments $save_dir = '/path/to/save/attachments/'; foreach($attachments as $attachment) { // get the attachment name $filename = $attachment->filename; // write the file to the directory you want to save it in if ($fp = fopen($save_dir.$filename, 'w')) { while($bytes = $attachment->read()) { fwrite($fp, $bytes); } fclose($fp); } } ?> Hope this helps. ---- Server IP: 69.147.83.197 Probable Submitter: 76.110.124.22 ---- Manual Page -- http://www.php.net/manual/en/book.mailparse.php Edit -- https://master.php.net/note/edit/100558 Del: integrated -- https://master.php.net/note/delete/100558/integrated Del: useless -- https://master.php.net/note/delete/100558/useless Del: bad code -- https://master.php.net/note/delete/100558/bad+code Del: spam -- https://master.php.net/note/delete/100558/spam Del: non-english -- https://master.php.net/note/delete/100558/non-english Del: in docs -- https://master.php.net/note/delete/100558/in+docs Del: other reasons-- https://master.php.net/note/delete/100558 Reject -- https://master.php.net/note/reject/100558 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#173392) next »