riddlestone/brokkr-mail
Composer 安装命令:
composer require riddlestone/brokkr-mail
包简介
A Laminas module to provide service-manager built and configured mail transports
README 文档
README
A Laminas module to provide service-manager built and configured mail transports
Installation
Installation of this module uses composer. For composer documentation, please refer to getcomposer.org.
composer require riddlestone/brokkr-mail
Usage
Building a Message
This module adds a factory for generating messages with content created using Laminas View.
// 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', ], );
Once created, you will need to set the subject, and other header fields (such as To, From, etc.).
The created message will have two alternate mime-parts: text and HTML. If the text template is omitted, the text will be created from the HTML content.
Building a Transport
This module adds a factory for Laminas\Mail\Transport\TransportInterface which creates it from configuration at
mail.transport.
For example, to use a shared SMTP transport:
// local.config.php return [ 'mail' => [ 'transport' => [ 'type' => 'smtp', 'options' => [ 'name' => 'smtp.example.com', 'host' => 'smtp.example.com', 'connection_class' => 'login', 'connection_config' => [ 'username' => 'me@example.com', '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);
For more details on the configuration options, see the Laminas Mail Docs.
Get Involved
File issues at https://github.com/riddlestone/brokkr-mail/issues
统计信息
- 总下载量: 121
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2020-05-08