1. Go to this page and download the library: Download httd1/mailreplace 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/ */
httd1 / mailreplace example snippets
ilReplace\MailReplace;
$template = __DIR__.'/template.html';
$new_html = MailReplace::replaceFile ($template, [
'{{user}}' => 'ET Bilu',
'{{title}}' => 'Mail',
'[[[date_time]]]' => date ('m/d/y')
]);
echo $new_html;
// $template = <<<TEXT
// <!DOCTYPE html>
// <html>
// <head>
// <body>
// <h1 style="font-size: 14pt;">
// {{title}} - [[[date_time]]]
// </h1>
// <p>Hi {{user}}, this is a contact message, how are you?</p>
// </body>
// </head>
// </html>
// TEXT;
## save in new_template.html
// MailReplace::replaceToFile (__DIR__.'/new_template.html', $template, [
// '{{user}}' => 'ET Bilu',
// '{{title}}' => 'Mail',
// '[[[date_time]]]' => date ('m/d/y')
// ]);
// $html = MailReplace::replace ($template, [
// '{{user}}' => 'ET Bilu',
// '{{title}}' => 'Mail',
// '[[[date_time]]]' => date ('m/d/y')
// ]);
// echo $html;
/*
<!DOCTYPE html>
<html>
<head>
<body>
<h1 style="font-size: 14pt;">
Mail - 11/14/22
</h1>
<p>Hi ET Bilu, this is a contact message, how are you?</p>
</body>
</head>
</html>
*/
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.