add utils
This commit is contained in:
parent
aaa629a385
commit
21807d2eed
|
@ -1 +1,43 @@
|
||||||
# Mail
|
# Mail
|
||||||
|
|
||||||
|
`App\Core\Notification\MailNotifier` is a service and helps you to create a mail using twig template.
|
||||||
|
|
||||||
|
Useful methods:
|
||||||
|
|
||||||
|
* `setRecipients(array $recipients): MailNotifier`
|
||||||
|
* `setBccRecipients(array $bccRecipients): MailNotifier`
|
||||||
|
* `setSubject(?string $subject): MailNotifier`
|
||||||
|
* `setFrom($from): MailNotifier`
|
||||||
|
* `setReplyTo($replyTo): MailNotifier`
|
||||||
|
* `setAttachments(array $attachments): MailNotifier`
|
||||||
|
* `addRecipient(string $email, bool $isBcc = false): MailNotifier`
|
||||||
|
* `addRecipients(array $emails, bool $isBcc = false): MailNotifier`
|
||||||
|
* `addAttachment(string $attachment): MailNotifier`
|
||||||
|
* `addAttachments(array $attachments): MailNotifier`
|
||||||
|
* `init(): MailNotifier`
|
||||||
|
* `notify(string $template, array $data = [], string $type = 'text/html'): MailNotifier`
|
||||||
|
|
||||||
|
Exemple:
|
||||||
|
|
||||||
|
```
|
||||||
|
use App\Core\Notification\MailNotifier;
|
||||||
|
|
||||||
|
public function foo(MailNotifier $notifier)
|
||||||
|
{
|
||||||
|
// ...
|
||||||
|
|
||||||
|
$notifier
|
||||||
|
->init()
|
||||||
|
->setSubject('Your bill')
|
||||||
|
->addRecipient('john.doe@example.com')
|
||||||
|
->addRecipients([
|
||||||
|
'admin@example-shop.com',
|
||||||
|
'sales@example-shop.com',
|
||||||
|
], true)
|
||||||
|
->addAttachment('path/to/bill.pdf')
|
||||||
|
->notify('mail/bill.html.twig', [
|
||||||
|
// view params
|
||||||
|
])
|
||||||
|
;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in a new issue