FAUSTINE MWOYA November 18, 2025 1 min read

Jinsi ya Kutengeneza Email Templates kwa Notifications | Rahisi na Fupi

Jifunze kutengeneza email templates kwa PHP ili kutuma notifications kama welcome email, password reset, alerts, au system updates. Mwongozo mfupi wenye mfano wa template na code ya kuituma.

✅ 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

🚀 Unahitaji mfumo au website ya biashara?

Chagua huduma hapa chini kisha mteja bofya moja kwa moja kwenda kwenye ukurasa wa huduma au kuwasiliana nasi kwa WhatsApp.

Share this post

Comments

0
No comments yet. Be the first to comment.

Continue Reading

Subscribe

Get new updates

Jiunge upokee posts mpya, tutorials, na updates za mifumo moja kwa moja kwenye email yako.

Faulink Support