delboy1978uk / bone-mail
Mail package for Bone Framework
v1.2.3
2024-11-13 16:02 UTC
Requires
- php: ^8.2
- boneframework/bone: ^3.11
- laminas/laminas-mail: ^2.22
- laminas/laminas-servicemanager: ^3.3
Requires (Dev)
- delboy1978uk/dev-tools: ^1.0
- roave/security-advisories: dev-master
README
Mail package for Bone Framework
installation
Use Composer
composer require delboy1978uk/bone-mail
usage
Simply add to the config/packages.php
<?php // use statements here use Bone\Mail\MailPackage; return [ 'packages' => [ // packages here..., MailPackage::class, ], // ... ];
Add a config/mail.php
in the config folder.
<?php // the docker dev box uses these Mailhog settings return [ 'mail' => [ 'name' => 'mail', // or 127.0.0.1 etc 'host' => 'mail', // or localhost etc 'port' => 1025, // or 25 ], ];
sending email
Any classes that need set up with the Bone\Mail\Service\MailService
can have it injected via your package class
(remember and add a use statement with the full class) :
$mailService = $c->get(MailService::class);
With regards to the setTemplate()
method, refer to the league/plates
docs, and delboy1978uk/bone-user
for an
example. Variables set in setViewData()
go to your view template.
$mail = new EmailMessage(); $mail->setTo($email); $mail->setSubject($subject); $mail->setTemplate('email.user::user_registration/change_email'); $mail->setViewData([ 'siteUrl' => $env->getSiteURL(), 'logo' => $this->getSiteConfig()->getEmailLogo(), 'resetLink' => '/user/reset-email/' . $email . '/' . $newEmail . '/' . $token, ]); $this->mailService->sendEmail($mail);