$ show nette/mail
Nette Mail is a standalone PHP library for creating and sending emails with support for SMTP, sendmail, DKIM signing, and fallback mechanisms. It provides a clean API for composing emails with HTML/text bodies, attachments, embedded images, and automatic text alternative generation. The architecture follows a modular design with separate concerns for message creation (Message/MimePart), sending (multiple Mailer implementations), signing (DkimSigner), and HTML processing (HtmlComposer, CssInliner). The library is framework-agnostic but integrates well with Nette DI and Tracy debugging tools.
The LLM identified 3 files worth highlighting for reuse:
A sophisticated CSS parser and inliner that tokenizes CSS, calculates selector specificity, handles cascade order and importance, and converts CSS rules to inline style attributes for email client compatibility. It preserves <style> tags for media queries and generates HTML attributes for Outlook support. The implementation demonstrates advanced parsing techniques with a custom tokenizer, balanced bracket handling, and proper CSS nesting support.
A clean implementation of the decorator pattern that wraps any Mailer to add email redirecting capabilities and event firing. It safely clones messages to modify headers without affecting the original, preserves original recipients in X-Original-* headers, and fires $onSent events with both success and failure states. The component is highly decoupled, depending only on the Mailer interface and Message class.
A robust fallback mechanism that tries multiple mailers in sequence with retry logic. It distinguishes between permanent and transient failures to optimize retry behavior, invokes onFailure callbacks for monitoring, and aggregates all failures into a FallbackMailerException only when all attempts are exhausted. The implementation shows careful consideration of SMTP failure semantics and efficient resource usage.