Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/charcoalphp/email
[READ-ONLY] Charcoal email sending (with phpmailer) and queue management.
https://github.com/charcoalphp/email
email email-sender php phpmailer queue read-only-repository
Last synced: about 1 month ago
JSON representation
[READ-ONLY] Charcoal email sending (with phpmailer) and queue management.
- Host: GitHub
- URL: https://github.com/charcoalphp/email
- Owner: charcoalphp
- License: mit
- Created: 2022-06-21T15:43:49.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-13T15:05:14.000Z (9 months ago)
- Last Synced: 2024-04-14T05:10:25.478Z (8 months ago)
- Topics: email, email-sender, php, phpmailer, queue, read-only-repository
- Language: PHP
- Homepage: https://github.com/charcoalphp/charcoal
- Size: 1.28 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Charcoal Email
==============The Email package provides an integration with [PHPMailer] for sending emails.
## Installation
```shell
composer require charcoal/email
```For Charcoal projects, the service provider can be registered from your configuration file:
```json
{
"service_providers": {
"charcoal/email/service-provider/email": {}
}
}
```## Usage
```php
use Charcoal\Email\ServiceProvider\EmailServiceProvider;
use Pimple\Container;$container = new Container();
$container->register(new EmailServiceProvider());$email = $container['email'];
$email->setData([
'from' => '"Company inc." ',
'bcc' => '[email protected]',
'to' => [
'[email protected]',
'"Some guy" ',
[
'name' => 'Other guy',
'email' => '[email protected]',
],
],
'reply_to' => [
'name' => 'Jack CEO',
'email' => '[email protected]'
],
'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.
```json
{
"email": {
"smtp": true,
"smtp_hostname": "smtp.example.com",
"smtp_port": 25,
"smtp_security": "tls",
"smtp_username": "[email protected]",
"smtp_password": "password","default_from": "[email protected]",
"default_reply_to": "[email protected]",
"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** | `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`.## Resources
* [Contributing](https://github.com/charcoalphp/.github/blob/main/CONTRIBUTING.md)
* [Report issues](https://github.com/charcoalphp/charcoal/issues) and
[send pull requests](https://github.com/charcoalphp/charcoal/pulls)
in the [main Charcoal repository](https://github.com/charcoalphp/charcoal)[PHPMailer]: https://github.com/PHPMailer/PHPMailer