PHP code example of riddlestone / brokkr-mail
1. Go to this page and download the library: Download riddlestone/brokkr-mail library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
riddlestone / brokkr-mail example snippets
// local.config.php
return [
'view_manager' => [
'template_path_stack' => [
__DIR__ . '/../views',
],
],
];
// some_factory_or_service.php
use Laminas\ServiceManager\ServiceManager;
use Riddlestone\Brokkr\Mail\MessageFactory;
/** @var ServiceManager $serviceManager */
$messageFactory = $serviceManager->get(MessageFactory::class);
$message = $messageFactory(
'mail/my-html-template',
'mail/my-text-template',
[
'view_variable_1' => 'Some value',
'view_variable_2' => 'Some other value',
],
);
// local.config.php
return [
'mail' => [
'transport' => [
'type' => 'smtp',
'options' => [
'name' => 'smtp.example.com',
'host' => 'smtp.example.com',
'connection_class' => 'login',
'connection_config' => [
'username' => '[email protected] ',
'password' => 'my-p@ssw0rd',
],
],
],
],
];
// some_factory_or_service.php
use Laminas\Mail\Message;
use Laminas\Mail\Transport\TransportInterface;
use Laminas\ServiceManager\ServiceManager;
/** @var ServiceManager $serviceManager */
/** @var Message $message */
/** @var TransportInterface $transport */
$transport = $serviceManager->get(TransportInterface::class);
$transport->send($message);