Componette

Componette

rixxi

rixxi / mail-message-template

KISS library for generating mail messages from single template

download-cloud-line composer require rixxi/mail-message-template

Install

composer require rixxi/mail-message-template

Configure

extensions:
  rixxiMailMessageTemplate: Rixxi\Mail\DI\MessageTemplateExtension

Use

Template

Create template with subject, body and html body. All parts are optional.

{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}

Code

$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);

\\ ...

Creating from file template will allow you to utilize Nette\Mail\Message auto-inlining of template content for html body. You can alternatively use createFromString for creating message from string.

No release at this moment. Try to create first one.

bar-chart-fill

Statistics

download-cloud-fill
917
star-fill
2
bug-fill
3
flashlight-fill
7.3y
price-tag-2-line

Badges

guide-fill

Dependencies

Componette Componette felix@nette.org