Cara membuat web host manager sendiri V10 Notifikasi Email Otomatis untuk Expired Hosting

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 Otomatis untuk Expired Hosting di WHM Custom.

Fitur yang Akan Dibuat:

  • User mendapatkan email sebelum akun hosting mereka expired.
  • Email berisi informasi tanggal kadaluarsa & cara memperpanjang.
  • Admin bisa melihat daftar akun yang akan expired.
  • Gunakan Cron Job agar email terkirim otomatis setiap hari.

1️⃣ Tambahkan Kolom Expired Date di Database

📌 Jalankan SQL ini untuk menambahkan kolom expired date di tabel accounts

ALTER TABLE accounts ADD COLUMN expired_date DATE NOT NULL AFTER status;

📌 Setiap akun sekarang punya tanggal kadaluarsa hosting.


2️⃣ Buat Cron Job untuk Mengirim Notifikasi Expired

📌 File cron/check_expired.php

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

// Ambil akun yang akan expired dalam 7 hari
$date = date('Y-m-d', strtotime('+7 days'));
$stmt = $conn->prepare("SELECT id, username, email, expired_date FROM accounts WHERE expired_date = ?");
$stmt->bind_param("s", $date);
$stmt->execute();
$result = $stmt->get_result();

while ($row = $result->fetch_assoc()) {
    $username = $row['username'];
    $email = $row['email'];
    $expired_date = $row['expired_date'];

    // Kirim email peringatan
    $subject = "Peringatan: Hosting Anda Akan Kadaluarsa!";
    $message = "
        <h2>Halo, $username</h2>
        <p>Akun hosting Anda akan kadaluarsa pada <b>$expired_date</b>.</p>
        <p>Segera lakukan perpanjangan untuk menghindari suspensi akun.</p>
        <p><a href='https://yourdomain.com/renew.php'>Perpanjang Sekarang</a></p>
        <p>Terima kasih telah menggunakan layanan kami.</p>
        <p><b>Tim Hosting</b></p>
    ";

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

echo "Notifikasi expired berhasil dikirim!";
?>

📌 Script ini akan mencari akun yang expired dalam 7 hari dan mengirimkan email peringatan.


3️⃣ Tambahkan Cron Job di Server

📌 Jalankan perintah ini di terminal (jika menggunakan VPS):

crontab -e

📌 Tambahkan baris berikut untuk menjalankan script setiap hari pukul 00:00

0 0 * * * /usr/bin/php /path/to/cron/check_expired.php

📌 Pastikan /path/to/cron/check_expired.php sesuai dengan lokasi file di server Anda.


4️⃣ Buat Halaman Admin untuk Melihat Akun yang Akan Expired

📌 File admin/expiring_accounts.php

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

// Ambil akun yang akan expired dalam 7 hari
$date = date('Y-m-d', strtotime('+7 days'));
$result = $conn->query("SELECT id, username, email, expired_date FROM accounts WHERE expired_date = '$date'");

?>
<h2>Akun yang Akan Expired</h2>
<table border="1">
    <tr>
        <th>Username</th>
        <th>Email</th>
        <th>Expired Date</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><?php echo $row['expired_date']; ?></td>
        <td>
            <a href="renew_account.php?id=<?php echo $row['id']; ?>">Perpanjang</a>
        </td>
    </tr>
    <?php } ?>
</table>

📌 Admin bisa melihat akun yang akan expired dan memperpanjangnya.


5️⃣ Buat Halaman Perpanjangan Akun

📌 File renew_account.php

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

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

    // Perpanjang expired date 1 bulan
    $stmt = $conn->prepare("UPDATE accounts SET expired_date = DATE_ADD(expired_date, INTERVAL 1 MONTH) WHERE id=?");
    $stmt->bind_param("i", $account_id);
    $stmt->execute();

    echo "Akun berhasil diperpanjang 1 bulan!";
}
?>

📌 Admin bisa memperpanjang expired date akun dengan sekali klik!


🔥 Sekarang WHM Custom Bisa Kirim Notifikasi Expired Otomatis!

User dapat email peringatan sebelum akun expired.
Admin bisa melihat daftar akun yang akan expired.
Admin bisa memperpanjang akun dengan satu klik.
Cron job berjalan otomatis setiap hari.

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.