Open-source PHP library that transforms raw emails and EML files into structured business data — spam scores, invoices, orders, leads, phishing reports, and more.
Capabilities
One library. Zero external calls. Full intelligence from raw bytes to structured data.
Live Preview
Real EML files from the test suite, parsed and analyzed.
EmailParser::parse() returns for each fixture
Quick Start
Requires PHP 8.2+, ext-mbstring, ext-json
Parse raw email strings or EML files with one call
All detection is lazy-loaded. Zero configuration needed
use MailSage\EmailParser; // Parse from raw email string $email = EmailParser::parse($rawEmail); // Or parse directly from an EML file $email = EmailParser::fromFile('path/to/email.eml'); // Core fields $email->subject(); // "Invoice INV-2026-0547" $email->sender(); // ['name' => 'Acme Corp', 'email' => '...'] $email->body(); // Plain text body $email->htmlBody(); // HTML body // Intelligence $email->category(); // "invoice" $email->confidence(); // 95 $email->isSpam(); // false $email->isPhishing(); // false $email->isInvoice(); // true // Invoice extraction $invoice = $email->invoice(); $invoice->number(); // "INV-2026-0547" $invoice->amount(); // 1595.00 $invoice->currency(); // "USD" $invoice->vendor(); // "billing@acmecorp.com" // Attachments $email->attachments()->count(); // 1 $email->attachments()->highestRiskLevel();// "low" $email->saveAttachments('/uploads');