Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Mail Mime Parser Laravel Package

zbateson/mail-mime-parser

PSR-compliant, testable MIME email parser for PHP 8.1+ as an alternative to imap* and PEAR. Parses RFC 822/2822/5322 messages from strings, resources, or PSR-7 streams; standards-compliant yet forgiving, with a cleaned-up 4.x API.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Email Processing Pipeline: Enables parsing raw email messages (e.g., from IMAP, SMTP, or file uploads) into structured data for downstream processing (e.g., spam filtering, analytics, or archiving).
  • Compliance & Security Features: Supports S/MIME and PGP/MIME encryption/signing via companion packages, critical for:
    • HIPAA/GDPR-compliant email handling (e.g., decrypting patient emails in healthcare).
    • Secure internal communications (e.g., legal/financial firms).
  • Build vs. Buy: Buy over custom solutions for:
    • Teams lacking MIME/RFC expertise (reduces dev time by 60–80%).
    • Projects needing PSR-compliant, tested parsing (vs. reinventing wheel).
  • Use Cases:
    • Email Archiving: Extract metadata/attachments for long-term storage (e.g., legal hold).
    • Marketing Automation: Parse campaign emails to track opens/clicks via embedded pixels.
    • Customer Support: Route emails with attachments (e.g., invoices) to workflows.
    • Fraud Detection: Analyze email headers (e.g., Received chains) for spoofing.

When to Consider This Package

Adopt if:

  • Your stack uses PHP 8.1+ and Laravel/Symfony (PSR-7 compatibility).
  • You need RFC 5322 compliance (e.g., parsing complex headers like List-Unsubscribe).
  • Attachments/encryption are core features (e.g., handling S/MIME or PGP emails).
  • You require structured data (e.g., extract From, To, Subject as objects, not strings).

Look elsewhere if:

  • You’re on PHP < 8.1 (use legacy imap_* functions or PEAR libraries).
  • Your use case is simple (e.g., sending emails; use Laravel’s Mailable).
  • You need real-time parsing (e.g., streaming large emails; consider SwiftMailer or Zend Mail).
  • Your team lacks PHP expertise (higher learning curve than Laravel’s built-in Mail facade).

How to Pitch It (Stakeholders)

For Executives: "This package replaces fragile, outdated email parsing (e.g., imap_* functions) with a modern, RFC-compliant solution that handles encrypted emails and attachments—critical for [compliance/security use case]. It cuts dev time by 70% while supporting features like S/MIME for [industry-specific need]. The BSD license avoids vendor lock-in, and active maintenance ensures long-term viability."

For Engineering: *"Leverage this to:

  1. Replace imap_* hacks: Get structured headers/attachments with zero regex.
  2. Add encryption support: Plug in zbateson/mmp-crypt-smime for HIPAA/GDPR emails.
  3. Integrate with Laravel: Parse incoming emails (e.g., from Mail::raw()) into objects for workflows.
  4. Future-proof: PSR-7 streams enable compatibility with Guzzle, Symfony Mailer, etc. Tradeoff: Slightly steeper learning curve than Laravel’s Mail facade, but 10x more robust for complex emails."*

For Developers: *"Key wins:

  • No more preg_match hell: Parse multipart/mixed emails with ->getAttachmentPart(0).
  • Attachments as streams: Use ->getContentStream() to pipe files directly to S3 or databases.
  • Header deep dives: Extract ->getHeader('X-Custom-Header')->getValue() without manual parsing.
  • Encryption out of the box: Add zbateson/mmp-crypt-gpg to handle PGP emails. Example workflow:
$email = MailMimeParser::parse($rawEmail);
$invoice = $email->getAttachmentPart(0)->saveContent('invoices/' . uniqid() . '.pdf');
// Now process $invoice with Laravel’s Filesystem.
```"*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation