PHP code example of mote / email-templater
1. Go to this page and download the library: Download mote/email-templater 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/ */
mote / email-templater example snippets
use Mote\EmailTemplater as Et;
$templater = new Et\Templater(...);
$transport = new \Zend\Mail\Transport\Sendmail();
try {
$zendMessage = $templater->fromTemplate(
'myEmailTemplate',
array(
'templateParam1' => 'Something...',
'templateParam2' => 'Something else...',
)
)->convert('zf2'); // Or just ->convert() if "zf2" is set in constructor as default
$zendMessage->setFrom('admin@localhost')
->setTo('[email protected]');
$transport->send($zendMessage);
} catch (Et\TemplateNotFoundException $e) {
echo 'Could not find template';
} catch (Et\Processor\InvalidTemplateException $e) {
echo 'The template found was invalid';
} catch (Et\Processor\ProcessingException $e) {
echo 'Generic processing exception';
}