rixxi / mail-message-template
0.1.0
2014-06-09 20:30 UTC
Requires
- latte/latte: ~2.2
- nette/nette: ~2.2
Suggests
- nette/di: ~2.2
This package is not auto-updated.
Last update: 2024-09-24 02:21:50 UTC
README
composer require rixxi/mail-message-template
配置
extensions: rixxiMailMessageTemplate: Rixxi\Mail\DI\MessageTemplateExtension
使用
模板
使用主题、正文和HTML正文创建模板。所有部分都是可选的。
{subject}Welcome to our site {$user->name}{/subject} {body} Oh how we are so grateful {$user->name} that you decided to join our awesome service. Sincerly, yours CEO Only Man in the Company {/body} {body html} {* text is default *} <marquee>Oh how we are so grateful {$user->name} that you decided to join our awesome service.<marquee> <p> Sincerly,<br /> yours <strong>CEO</strong><br /> Only Man in the Company </p> {/body}
代码
$message = $messageFactory->createFromFile(__DIR__ . '/../mails/registration.latte', array( 'user' => (object) array( 'name' => 'Name Surname', ), )); // message will have set subject, body and its html alternative // setup other stuff and send $message->addTo($user->email); $message->setFrom('example@example.com'); $this->sender->send($message); \\ ...
从文件模板创建将允许您利用 Nette\Mail\Message
自动内联模板内容以用于HTML正文。您也可以使用 createFromString
从字符串创建消息。