charcoal / email
Email sending and queueing for Charcoal
Installs: 11
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
pkg:composer/charcoal/email
Requires
- php: ^7.4 || ^8.0
- ext-pdo: *
- charcoal/app: ^5.0
- charcoal/config: ^5.0
- charcoal/queue: ^5.0
- phpmailer/phpmailer: ~6.0
- psr/log: ^1.0
- seld/jsonlint: ^1.9
Requires (Dev)
- mustache/mustache: ^2.11
- php-coveralls/php-coveralls: ^2.2
- phpstan/phpstan: ^1.6
- phpunit/phpunit: ^9.5
- pimple/pimple: ^3.0
- squizlabs/php_codesniffer: ^3.5
Replaces
- dev-main / 5.x-dev
- v5.0.0
- v4.1.0
- v4.0.8
- v4.0.7
- v4.0.6
- v4.0.5
- v4.0.4
- v4.0.2
- v4.0.1
- v4.0.0
- v3.1.8
- v3.1.7
- v3.1.6
- v3.1.5
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v2.2.3
- v2.2.2
- v2.2.1
- v2.2.0
- v2.1.2
- 0.7.2.1
- 0.7.2
- 0.7.1.1
- 0.7.1
- 0.7.0.1
- 0.7.0
- 0.6.0
- 0.4.4.1
- 0.4.4
- 0.4.3
- 0.4.2
- 0.4.1.1
- 0.4.1
- 0.4.0.2
- 0.4.0.1
- 0.4.0
- 0.3.3.2
- 0.3.3.1
- 0.3.3
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.4
- 0.2.3
- 0.2.1
- 0.2
- 0.1.3
- 0.1.2
- 0.1.1
- 0.1
- dev-feature/camelizePropertiesAndUseArrayAccess
This package is auto-updated.
Last update: 2025-10-13 19:04:37 UTC
README
The Email package provides an integration with PHPMailer for sending emails.
Installation
composer require charcoal/email
For Charcoal projects, the service provider can be registered from your configuration file:
{
"service_providers": {
"charcoal/email/service-provider/email": {}
}
}
Usage
use Charcoal\Email\ServiceProvider\EmailServiceProvider; use Pimple\Container; $container = new Container(); $container->register(new EmailServiceProvider()); $email = $container['email']; $email->setData([ 'from' => '"Company inc." <company.inc@example.com>', 'bcc' => 'shadow@example.com', 'to' => [ 'recipient@example.com', '"Some guy" <someguy@example.com>', [ 'name' => 'Other guy', 'email' => 'otherguy@example.com', ], ], 'reply_to' => [ 'name' => 'Jack CEO', 'email' => 'jack@example.com' ], 'subject' => $this->translator->trans('Email subject'), 'campaign' => 'Campaign identifier', 'template_ident' => 'foo/email/default-email' 'attachments' => [ 'foo/bar.pdf', 'foo/baz.pdf', ], ]); // Dispatch immediately: $email->send(); // Alternately, dispatch at a later date using the queue system: $email->queue('in 5 minutes');
Email Config
The entire email system can be configured from the main app config, in the email config key.
{
"email": {
"smtp": true,
"smtp_hostname": "smtp.example.com",
"smtp_port": 25,
"smtp_security": "tls",
"smtp_username": "user@example.com",
"smtp_password": "password",
"default_from": "webproject@example.com",
"default_reply_to": "webproject@example.com",
"default_track": false,
"default_log": true
}
}
Service Provider
All email services can be quickly registered to a service container with \Charcoal\Email\ServiceProvider\EmailServiceProvider.
Provided services:
| Service | Type | Description |
|---|---|---|
Email[1] |
An email object (factory). | |
| email/factory | FactoryInterface[2] |
An email factory, to create email objects. |
Notes:
- [1]
\Charcoal\Email\Email. - [2]
Charcoal\Factory\FactoryInterface.
Also available are the following helpers:
| Helper Service | Type | Description |
|---|---|---|
| email/config | EmailConfig[3] |
Email configuration. |
| email/view | ViewInterface[4] |
The view object to render email templates ($container['view']). |
Notes:
- [3]
\Charcoal\Email\EmailConfig. - [4]
\Charcoal\View\ViewInterface.