atreo / mailer
Email service with latte templates for Nette Framework.
v1.0.8
2016-11-28 11:16 UTC
Requires
- atreo/ui: ~2.0@dev
- nette/di: ~2.3
- nette/mail: ~2.3
- nette/utils: ~2.3
This package is not auto-updated.
Last update: 2024-11-01 19:09:56 UTC
README
Installation
$ composer require atreo/mailer
Extension configuration:
mailer: Atreo\Mailer\DI\MailerExtension
mailer:
templatesDir: %appDir%/Templates/@emails
catchExceptions: true
sender: false # or your custom sender for example: @rabbitMqSender
Use mailer:
/**
* @inject
* @var \Atreo\Mailer\Mailer
*/
public $mailer;
// you can use basic email class
$email = new Email();
$email->addRecipient('test@test.cz', 'Testovací Uživatel');
$email->setBody('Testovací email');
$this->mailer->send($email);
// or you can use your own email class
$this->mailer->send(new ForgottenPasswordEmail($user, $resetKey));
// class definition
class ForgottenPasswordEmail extends Email
{
/**
* @param \App\Entity\User $user
*/
public function __construct(User $user)
{
$this->setSubject("Obnovení hesla");
$this->addRecipient($user->email, $user->name);
$this->setTemplateBody(['user' => $user]);
}
}