httd1/mailreplace

v2.0.0 2022-11-24 12:58 UTC

This package is auto-updated.

Last update: 2024-10-24 16:47:42 UTC


README

Install

composer require httd1/mailreplace

Usage

<?php

include __DIR__.'/vendor/autoload.php';

use MailReplace\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>
*/