https://github.com/jaymon/emailparse
Easily parse emails in PHP
https://github.com/jaymon/emailparse
email email-parsing php-library
Last synced: 28 days ago
JSON representation
Easily parse emails in PHP
- Host: GitHub
- URL: https://github.com/jaymon/emailparse
- Owner: Jaymon
- Created: 2013-02-22T00:43:21.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2013-02-22T00:46:29.000Z (over 13 years ago)
- Last Synced: 2025-01-08T22:38:21.245Z (over 1 year ago)
- Topics: email, email-parsing, php-library
- Language: PHP
- Size: 117 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# EmailParse
Easy parsing of emails in PHP
## Parse an email
include_once('EmailMap.php');
include_once('EmailParse.php');
// $input is a raw email string
// get $input from some other php library like a pop3 library or something
$ep = new EmailParse();
$email_map = $ep->parse($input);
print_r($email_map->getTo()); // getTo() returns a list since there can be more than one to address
echo $email_map->getFrom();
echo $email->getSubject();
echo $email->getPlainBody();
print_r($email_map->getAttachments());
## Todo
Right now you have to have the full email before you can parse it, some email can be pretty big
if they have lots of attachments (or one really big attachment). So it would probably be prudent
to make `parse()` be able to take a file-pointer so it can read in the email line by line or something.
I haven't done this yet because it's never been a problem in the places I use this lib.
## License
MIT, pull requests encouraged.