Download the PHP package gryfoss/twig-smart-mailer without Composer
On this page you can find all versions of the php package gryfoss/twig-smart-mailer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gryfoss/twig-smart-mailer
More information about gryfoss/twig-smart-mailer
Files in gryfoss/twig-smart-mailer
Package twig-smart-mailer
Short Description Smart mailer based on Symfony Mailer which supports dynamic source mailboxes and easy integration of files within emails
License MIT
Informations about the package twig-smart-mailer
GryfOSS: Twig Smart Mailer
Smart mailer is a simple library which assists sending of emails with use of symfony/mailer component. At the moment it requires SMTP connection, but grants features like easy embedding of images, easier attachments adding, exceptions tracking and use of string templates instead of files.
Features
- Twig Template Support: Use Twig syntax in both HTML and text email content
- Easy File Attachments: Simple attachment management with validation
- Embedded Images: Support for inline images with automatic MIME type detection
- Multiple Recipients: Support for To, CC, and BCC recipients
- DSN Configuration: Flexible transport configuration via DSN strings
- Gmail Integration: Built-in Gmail transport support
- Testing Support: File-based mailer for development and testing
- Exception Handling: Comprehensive exception hierarchy for error handling
Quick Start
Library Structure
Core Classes
SmartMailer
Main email sending implementation with Twig template support. Integrates with Symfony Mailer for actual email delivery.
FakeFileSmartMailer
File-based implementation for testing and development. Writes email data to JSON files instead of sending actual emails.
Message
Represents an email message with all its components including recipients, content, attachments, and embedded images.
EmailAddress
Encapsulates an email address with optional display name and validation.
Attachment
Represents a file attachment with path validation and optional custom naming.
DSN (Data Source Name) Classes
DsnInterface
Interface for creating DSN strings compatible with Symfony Mailer.
Dsn\Smtp
SMTP server DSN implementation with full configuration options.
Dsn\Gmail
Simplified Gmail DSN implementation using Symfony's Gmail transport.
Configuration Enums
EncryptionMethod
Defines available SMTP encryption methods (SSL/TLS, STARTTLS, none).
LoginMethod
Defines available SMTP authentication methods (LOGIN, PLAIN, CRAM-MD5, etc.).
Exception Hierarchy
SmartMailerException
Base exception class for all library-specific errors.
InvalidEmailAddressException
Thrown when email address format validation fails.
InvalidAttachmentException
Thrown when attachment file doesn't exist or isn't readable.
InvalidEmailMessageException
Thrown when message validation fails (missing required fields).
InvalidImageException
Thrown when attempting to embed a non-image file.
NotUniqueEmbedNameException
Thrown when trying to add an embedded image with a duplicate name.
SendException
Thrown when email sending fails.
Advanced Usage
Using Gmail Transport
Embedded Images
You can easily embed any image by using content id of the resource. If your
filename is sample.png then to embed just place cid:sample.png in contents.
You can also define a custom name:
Warning: Embedded image names must be unique within a message!
Twig Templates
Both HTML and text content support Twig templating:
Testing with FakeFileSmartMailer
Error Handling
Requirements
- PHP 8.1+
- Symfony Mailer 6.0+ or 7.0+
- Twig 3.0+
Installation
Roadmap
1.0: tests, comments ✅ 2.0: other transports than SMTP Servers 3.0: Pub/Sub queues support
Contribution
Any pull requests or issues reported are more than welcome.
License
GPL 3+
All versions of twig-smart-mailer with dependencies
symfony/mailer Version ^6.0 || ^7.0
symfony/mime Version ^6.0 || ^7.0
symfony/twig-bridge Version ^6.0 || ^7.0
twig/extra-bundle Version ^3.4
twig/twig Version ^3