untuk configuration email menggunakan SMPTP saya menggunakan PHP MAILER dengan bentuk valuenya adalah array associative
<?php
namespace app\controllers;
use app\controllers\email\mailer; #panggil class mailer
use MiniMvc\Apps\Core\Bootstraping\Controller;
class gambar extends Controller
{
public function __construct()
{
// code here
}
public function confirmasi_password()
{
// data yang akan dikirim ke template email
$email = [
"to" =>"miyuki@gmail.com",
"subject" => "confirmasi email",
"message" => "hello worl",
"header" => "ini headernya",
];
// load template emailnya dan passing datanya
$view = mailer::confirmation($email);
// dump($view);
smptp_mail([
"to" => "hello@mail.com",
"subject" => "this is subject",
"message" => "this is message",
"header" => "this is header",
"template" => $view
]);
}
}
Style Template
ketika melakukan style, dan di template view email terdapat variabel tidak aktif, karena di kirim melalui controller yang berbeda.
solution :
commnent atau remove dulu variabel pada berkas view email tersebut
definisikan routingnya
$router->mount('/mail/message', function () use ($router) {
// $router->set404(function () {
// header('HTTP/1.1 404 Not Found');
// redirect_404();
// });
/**
* return get /mail/message/confirmation
*/
$router->get('confirmation', function () {
// echo "hi";
Routes::Routing("email/mailer", "confirmation");
});
});
aktifkan view() pada method mailer.php
public static function confirmation($data = [])
{
// return string
view("email.confirmation");
// return template("confirmation", $data);
}