https://github.com/dotkernel/dot-controller-plugin-mail
DotKernel mail controller plugin
https://github.com/dotkernel/dot-controller-plugin-mail
Last synced: 7 months ago
JSON representation
DotKernel mail controller plugin
- Host: GitHub
- URL: https://github.com/dotkernel/dot-controller-plugin-mail
- Owner: dotkernel
- License: mit
- Created: 2016-09-14T16:15:00.000Z (over 9 years ago)
- Default Branch: 2.9-PHP-8.1
- Last Pushed: 2024-06-03T05:20:52.000Z (over 1 year ago)
- Last Synced: 2025-04-18T09:44:41.685Z (8 months ago)
- Language: PHP
- Homepage:
- Size: 25.4 KB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
> [!CAUTION]
> ## Security-Only Maintenance Mode
>
> This package is considered feature-complete, and is now in **security-only** maintenance mode.

[](https://github.com/dotkernel/dot-controller-plugin-mail/blob/2.0.1/LICENSE.md)

# dot-controller-plugin-mail
Mail controller plugin for easy access to dot-mail service from any controller.
## Installation
Run the following command in your project's root directory
```bash
$ composer require dotkernel/dot-controller-plugin-mail
```
This will also install packages `dotkernel/dot-controller` and `'dotkernel/dot-mail` as dependencies.
Next, make sure you merge the `ConfigProvider` to your application's configuration.
## Usage
Because multiple mail services can be defined in the dot-mail module, there can also be requested as controller plugins by following the convention
```php
//calling this plugins without parameters, will return the mail service instead, otherwise will use parameters to send directly the e-mail
$this->sendMail(); //will return the default mail service
$this->sendMailYourMailService(); //will return the mail service named your_mail_service
```
Controller mail plugins are invokable. To send an email you can use the following 2 methods
* `$this->sendMail(array $mailConfig)` - will send a mail through a mail service configured based on the $mailConfig param.
The array parameter valid keys are body, subject, to, from, cc, bcc, attachments. The body parameter can be specified as an array too in which case the $body[0] should be the template name to use as mail template and $body[1] should be optionally the template parameters.
* `$this->sendMail($body, $subject, $to, $from, $cc, $bcc, $attachments)` - the parameters have the same meaning as in the previous method