💻
Code Zero Project
  • introduction
  • Welcome
  • getting started
    • apa itu mini mvc php native
    • Installation
  • architecture consept
  • database
    • PDO
    • connection
    • migrations
    • query builder
    • result database
  • basic
    • models
    • controller
    • view
    • routing
    • markdown
  • helper
    • session
    • input
    • maintenance
    • debug
    • waktu
    • agent
    • email
    • get_rest_api
    • upload directory
    • asset
    • 404
    • redirect
    • random file name
    • url
    • slug
    • upload files
    • read markdown
    • Security
  • frontend
    • basic html
  • libraries
  • science
    • mathecmatic
    • ML
  • command shell
  • API
  • donation
  • about
Powered by GitBook
On this page
  • Style Template
  • definisikan routingnya
  • aktifkan view() pada method mailer.php
  • check melalui url untuk melihat hasilnya
  1. helper

email

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);
	}

check melalui url untuk melihat hasilnya

http://localhost/mini-mvc-php-native/mail/message/confirmation

PreviousagentNextget_rest_api

Last updated 3 years ago