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

Zend Mime Laravel Package

zendframework/zend-mime

Zend\Mime is a PHP library for creating and parsing MIME messages. Build multipart emails, manage MIME parts, boundaries, headers, and content types/encodings, and handle attachments reliably—useful for mail composition and transport integration.

View on GitHub
Deep Wiki
Context7

Getting Started

Start by requiring the package via Composer (composer require zendframework/zend-mime). Despite being archived and last released in 2019, it remains compatible with modern PHP versions (5.6–8.0+) due to minimal dependencies and strict standards compliance. The primary use case is building and parsing MIME multipart messages—common in email generation (e.g., HTML + text + attachments). Begin with Zend\Mime\Mime and Zend\Mime\Message classes. For basic email sending, pair it with zendframework/zend-mail (which internally depends on this package). If using standalone, instantiate Zend\Mime\Message, set body parts via Zend\Mime\Part, and call $message->generateMessage() to output the raw MIME string.

Implementation Patterns

  • Email Composition: Build multipart messages by chaining addPart() with Zend\Mime\Part instances—set type, encoding, filename, and content for each (e.g., text/plain, text/html, application/pdf).
  • Dynamic Attachments: Use Zend\Mime\Part with isNewLine() to manage line endings correctly and setEncoding(Mime::ENCODING_BASE64) for binary files.
  • Standards Compliance: Leverage Mime::LINE_LENGTH constants (LONG, SHORT) to ensure RFC-compliant line wrapping.
  • Integration with PHPMailer/SwiftMailer: Even if not using zend-mail, you can generate MIME strings via Zend\Mime\Message and inject them as raw bodies into other mail libraries.
  • Testing: Mock Zend\Mime\Mime to assert generated message structure without relying on external mail servers.

Gotchas and Tips

  • Line Endings: Default is \r\n; use Zend\Mime::setLineEndings("\n") for Unix environments to avoid SMTP quirks (especially with sendmail).
  • Encoding Pitfalls: Non-ASCII filenames in attachments require Zend\Mime::ENCODING_BASE64 and charset=UTF-8 in typeParams. Failure here causes broken filenames in some clients (e.g., Outlook).
  • Deprecation Note: Prefer laminas/laminas-mime (the official successor fork) for active support—zendframework/zend-mime is deprecated but functionally stable for legacy/conservative projects.
  • Memory Optimization: For large attachments, avoid loading files entirely into memory—use Zend\Mime\Part with setFile() and setDiskFile() (via laminas/laminas-mime extension).
  • Debugging: Render messages with var_dump($message->generateMessage()) and validate using tools like MIME Validator or spamassassin --lint.
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
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
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