Cara membuat web host manager sendiri V9 Notifikasi Email ke User Saat Akun Disuspend

Me Nime Id
Please wait 0 seconds...
Scroll Down and click on Go to Link for destination
Congrats! Link is Generated

 Oke! Kita tambahkan fitur Notifikasi Email ke User Saat Akun Disuspend di WHM Custom.

Fitur yang Akan Dibuat:

  • User mendapatkan email saat akun mereka disuspend.
  • Email berisi alasan suspend dan cara mengaktifkan kembali akun.
  • Gunakan SMTP agar email tidak masuk spam.

1️⃣ Konfigurasi SMTP untuk Mengirim Email

📌 Install PHPMailer (jika menggunakan server VPS):

composer require phpmailer/phpmailer

📌 Atau, download PHPMailer dan ekstrak di folder includes/

📌 File includes/mail_config.php

<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';

function sendEmail($to, $subject, $message) {
    $mail = new PHPMailer(true);
    
    try {
        $mail->isSMTP();
        $mail->Host = 'smtp.gmail.com'; // Ganti dengan SMTP Provider (contoh: smtp.mailgun.org)
        $mail->SMTPAuth = true;
        $mail->Username = 'emailanda@gmail.com'; // Ganti dengan email pengirim
        $mail->Password = 'passwordemailanda';  // Ganti dengan password email atau App Password
        $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
        $mail->Port = 587;

        $mail->setFrom('emailanda@gmail.com', 'Admin Hosting');
        $mail->addAddress($to);

        $mail->isHTML(true);
        $mail->Subject = $subject;
        $mail->Body    = $message;

        $mail->send();
        return true;
    } catch (Exception $e) {
        return false;
    }
}
?>

📌 Sekarang kita bisa mengirim email dengan SMTP!


2️⃣ Update Script Suspend Akun dengan Notifikasi Email

📌 File admin/suspend_account.php

<?php
include '../includes/config.php';
include '../includes/mail_config.php';

if (isset($_GET['id'])) {
    $account_id = $_GET['id'];

    // Ambil informasi akun
    $stmt = $conn->prepare("SELECT username, email FROM accounts WHERE id=?");
    $stmt->bind_param("i", $account_id);
    $stmt->execute();
    $stmt->store_result();

    if ($stmt->num_rows > 0) {
        $stmt->bind_result($username, $email);
        $stmt->fetch();

        // Suspend akun di database
        $stmt = $conn->prepare("UPDATE accounts SET status='suspended' WHERE id=?");
        $stmt->bind_param("i", $account_id);
        $stmt->execute();

        // Kirim email notifikasi ke user
        $subject = "Akun Hosting Anda Telah Disuspend";
        $message = "
            <h2>Halo, $username</h2>
            <p>Akun hosting Anda telah disuspend karena alasan tertentu.</p>
            <p>Jika Anda merasa ini adalah kesalahan, silakan hubungi support kami.</p>
            <p>Terima kasih,</p>
            <p><b>Tim Hosting</b></p>
        ";

        sendEmail($email, $subject, $message);

        echo "Akun berhasil disuspend & email notifikasi telah dikirim!";
    } else {
        echo "Akun tidak ditemukan!";
    }
}
?>

📌 Saat admin suspend akun, user langsung dapat email notifikasi!


3️⃣ Cek Daftar Akun yang Suspended

📌 File admin/suspended_accounts.php

<?php
include '../includes/config.php';

$result = $conn->query("SELECT id, username, email FROM accounts WHERE status='suspended'");
?>
<h2>Daftar Akun Suspended</h2>
<table border="1">
    <tr>
        <th>Username</th>
        <th>Email</th>
        <th>Aksi</th>
    </tr>
    <?php while ($row = $result->fetch_assoc()) { ?>
    <tr>
        <td><?php echo $row['username']; ?></td>
        <td><?php echo $row['email']; ?></td>
        <td>
            <a href="reactivate_account.php?id=<?php echo $row['id']; ?>">Aktifkan Kembali</a>
        </td>
    </tr>
    <?php } ?>
</table>

📌 Admin bisa melihat daftar akun yang suspended & mengaktifkan kembali akun mereka.


4️⃣ Buat Script Mengaktifkan Kembali Akun

📌 File admin/reactivate_account.php

<?php
include '../includes/config.php';
include '../includes/mail_config.php';

if (isset($_GET['id'])) {
    $account_id = $_GET['id'];

    // Ambil informasi akun
    $stmt = $conn->prepare("SELECT username, email FROM accounts WHERE id=?");
    $stmt->bind_param("i", $account_id);
    $stmt->execute();
    $stmt->store_result();

    if ($stmt->num_rows > 0) {
        $stmt->bind_result($username, $email);
        $stmt->fetch();

        // Aktifkan kembali akun di database
        $stmt = $conn->prepare("UPDATE accounts SET status='active' WHERE id=?");
        $stmt->bind_param("i", $account_id);
        $stmt->execute();

        // Kirim email notifikasi ke user
        $subject = "Akun Hosting Anda Telah Diaktifkan Kembali";
        $message = "
            <h2>Halo, $username</h2>
            <p>Akun hosting Anda telah diaktifkan kembali.</p>
            <p>Terima kasih telah menggunakan layanan kami.</p>
            <p><b>Tim Hosting</b></p>
        ";

        sendEmail($email, $subject, $message);

        echo "Akun berhasil diaktifkan kembali & email notifikasi telah dikirim!";
    } else {
        echo "Akun tidak ditemukan!";
    }
}
?>

📌 Saat admin mengaktifkan kembali akun, user akan menerima email pemberitahuan!


🔥 Sekarang WHM Custom Bisa Kirim Notifikasi Email Saat Suspend!

Saat akun hosting disuspend, user dapat email otomatis.
Admin bisa melihat daftar akun yang disuspend.
Admin bisa mengaktifkan kembali akun, dan user dapat email notifikasi.

Posting Komentar

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.