Skip to content

juji/EmailParserPHP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 

Repository files navigation

EmailParser.php

Repository for a PHP email parse class

for more information on public functions, read the documentation.

Usage:

$parser = new EmailParser( file_get_contents('the/email/file') );
    
$text = $parser->getText();
$html = $parser->getHtml();
$attachments = $parser->getAttachments();
    

print "the text\n"
print_r($text);
print "=================================\n\n"
    
print "the html\n"
print_r($html);
print "=================================\n\n"
    
print "the attachment(s)\n"
print_r($attachments);

Result:
( all header keys has been converted to lowercaps, because i like it )

the text
Array
  (
    [header] => Array
      (
        [content-type] => text/plain; charset=windows-1252
        [content-transfer-encoding] => quoted-printable
      )
    [body] => some content
  )
=================================

the html
Array
  (
    [header] => Array
      (
        [content-type] => text/html; charset=windows-1252
        [content-transfer-encoding] => quoted-printable
      )
    [body] => <html><body><p>some <b>content</b></p></body></html>
  )
=================================

the attachment(s)
Array
  (
    [0] => Array
      (
        [header] => Array
          (
            [content-type] => image/jpeg; name="erika.jpg"
            [content-disposition] => attachment; filename="erika.jpg"
            [content-transfer-encoding] => base64
            [x-attachment-id] => f_hawb57bx5
          )
        [body] => /9j/4AAQSkZJ....
      )
    [1] => Array
      (
        [header] => Array
          (
            [content-type] => image/jpeg; name="erika2.jpg"
            [content-disposition] => attachment; filename="erika2.jpg"
            [content-transfer-encoding] => base64
            [x-attachment-id] => g_asdf7878
          )
        [body] => VEqnRHzUS4AW.....
      )
    )
  )

About

PHP email parse class

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages