Jinsi ya Kutengeneza Email Templates kwa Notifications | Rahisi na Fupi
✅ 1. Unda Folder la Templates
/templates/
welcome.php
reset_password.php
alert.php
✅ 2. Mfano wa Email Template (welcome.php)
<!DOCTYPE html>
<html>
<body style="font-family: Arial; line-height: 1.6;">
<h2>Karibu <?= $name ?>!</h2>
<p>Asante kwa kujiunga nasi. Akaunti yako imeundwa kikamilifu.</p>
<p>Kama hukufanya hili, tafadhali wasiliana nasi mara moja.</p>
</body>
</html>
✅ 3. Function ya Kupakia Template
<?php
function render_template($template, $data = []) {
$file = __DIR__ . "/templates/" . $template . ".php";
if (!file_exists($file)) return false;
extract($data);
ob_start();
include $file;
return ob_get_clean();
}
?>
✅ 4. Kutuma Email (PHP mail / PHPMailer)
$body = render_template("welcome", [
"name" => "John"
]);
$to = "john@example.com";
$subject = "Karibu John!";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
mail($to, $subject, $body, $headers);
✅ 5. Templates Nyingine zinazotumika Sana
🔹 Password Reset
<p>Hello <?= $name ?>, bofya link hii kurekebisha nenosiri:</p>
<a href="<?= $reset_link ?>"><?= $reset_link ?></a>
🔹 Alert / Notification
<h3>Notification Alert</h3>
<p><?= $message ?></p>
🔥 Faida za Kutumia Templates
Muonekano wa email unakuwa uniform
Customization rahisi kwa data mbalimbali
Inafanya system yako ionekane professional
Templates zinatenganisha logic & design
🔗 Links Za Kujifunza Zaidi
🌐 Faulink Official Website:
https://www.faulink.com/
📘 Jifunze Web Design & Programming (Tutorials / Mifumo):
https://www.faulink.com/excel_mifumo.php
📲 Piga / WhatsApp kwa msaada wa haraka:
https://wa.me/255693118509