ZF2 Module. Send mails, managing mail templates and mail log.
Clone this project into your ./vendor/
directory.
Add this project in your composer.json:
"require": {
"t4web/mail": "~1.0.0"
}
Now tell composer to download T4web\Mail
by running the command:
$ php composer.phar update
#### Post installation
Enabling it in your `application.config.php`file.
```php
<?php
return array(
'modules' => array(
// ...
'T4web\Mail',
),
// ...
);
For define mail templates, describe it in config:
't4web-mail' => [
// Global for all mails
'from-email' => 'support@your-domain.com',
// Global for all mails
'from-name' => 'Your project name',
'templates' => [
// Template id
T4web\Mail\Template::FEEDBACK_ANSWER => [
'subject' => 'Feedback answer',
'template' => 't4web-mail/template/feedback-answer',
'layout' => T4web\Mail\Template::LAYOUT_DEFAULT,
],
],
'layout' => [
// Layout id => layout template
T4web\Mail\Template::LAYOUT_DEFAULT => 't4web-mail/layout/default',
],
],
Template may be like this template/feedback-answer.phtml
$sender = $this->getServiceLocator()->get(\T4web\Mail\Sender::class);
$to = 'receiver@email.com';
$data = [
'userName' => 'Max',
'message' => 'My message',
'answer' => 'My answer',
];
$sender->send($to, \T4web\Mail\Template::FEEDBACK_ANSWER, $data);