Script Read Email PHP
Script Read Email PHP
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Read Email</title>
<script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify"></script>
<link href="https://cdn.jsdelivr.net/npm/@yaireo/tagify/dist/tagify.css"
rel="stylesheet" type="text/css" />
<style>
.image-container {
margin-bottom: 20px;
}
.image-container img {
max-width: 100%;
height: auto;
}
</style>
</head>
<body>
<h1>Read Email</h1>
<?php
if (isset($_GET['alert']) && $_GET['alert'] === '1') {
echo '<script>alert("Pesan tidak boleh kosong!");</script>';
}
if (isset($_GET['alert']) && $_GET['alert'] === '2') {
echo '<script>alert("Pesan Berhasil dikirim");</script>';
}
// Konfigurasi IMAP
$server = '{Mail.youdomain.com:143/notls}'; // Ganti dengan server IMAP Anda
$username = '[email protected]';
$password = 'password';
$mailbox = 'INBOX';
return $attachments;
}
// Jika pesan dalam format HTML, gunakan alternatif untuk mengambil pesan
if (empty($message)) {
$message = imap_fetchbody($connection, $mailId, 1);
}
// Hapus tag HTML dan tampilkan dalam tag <pre> untuk mempertahankan format
tabel
$message = strip_tags($message, '<table><tr><td>'); // Membiarkan hanya tag
tabel yang diizinkan
$message = "<pre>$message</pre>";
return $message;
}
// Menampilkan gambar
if (!empty($images)) {
echo "<h3>Gambar:</h3>";
foreach ($images as $image) {
echo "<div class='image-container'><a href='$image'
target='_blank'><img src='$image' alt='Embedded Image'></a></div>";
}
}
if (isset($_GET['mailId'])) {
$mailId = $_GET['mailId'];
} else {
// Tampilkan pesan kesalahan jika parameter tidak ditemukan
echo "Error: Mail ID not found in URL.";
exit; // Keluar dari skrip karena parameter tidak ada
}
<h2>Reply to Email</h2>
<form action="reply.php" method="post">
<input type="hidden" name="mailId" value="<?php echo $mailId; ?>">
<input type="hidden" name="replyMessageId" value="<?php echo $messageId; ?
>">
<input type="hidden" name="name" value="<?php echo $fromName; ?>">
<input type="hidden" name="email" value="<?php echo $fromEmail; ?>">
<input type="hidden" name="subject" value="<?php echo $subject; ?>">
<textarea name="replyMessage" rows="4" cols="50" placeholder="Type your
reply here..."></textarea><br>
<button type="submit" name="reply">Reply</button>
</form>
<script>
// The DOM element you wish to replace with Tagify
var input = document.querySelector('input[name=recipient[]]');