Nastavení v config.neon
extensions:
- NAttreid\Mailing\DI\MailingExtension
mailing:
sender: 'sender <[email protected]>'
variables: # v latte mailu promenne
title: 'Test.cz'
supportEmail: '[email protected]'
mailer:
- App/Mailer
- App/Mailer2('sender2 <[email protected]>')
Vytvořte třídu děděním z \NAttreid\Mailing\BaseMailer
class Mailer extends \NAttreid\Mailing\BaseMailer {
/**
* Odeslani linku pro zmenu hesla
* @param string $email
* @param string $hash
*/
public function sendRestorePassword($email, $hash) {
$mail = $this->createMail('template');
// nebo
$mail = $this->createMailFromString('<body><p>sablona jako string</p></body>);
$mail->link = $this->link('someLink', [
'hash' => $hash
]);
$mail->setSubject('translateMessage')
->addTo($email);
$mail->send();
}
Odeslání
/** @var \App\Services\Mailer @inject */
public $mailer;
$this->mailer->sendRestorePassword($email, $hash);