-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_email.php
81 lines (69 loc) · 2.64 KB
/
test_email.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
if(isset($_POST['send_email'])) {
$to_email = $_POST['email'];
$mail = new PHPMailer(true);
try {
// Server settings
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'theslbgamer@gmail.com';
$mail->Password = 'pudx zvxx uyid owvl';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;
// Recipients
$mail->setFrom('theslbgamer@gmail.com', 'SignEase');
$mail->addAddress($to_email);
// Content
$mail->isHTML(true);
$mail->Subject = 'Test Email';
$mail->Body = 'Hi';
$mail->send();
$success_message = "Email sent successfully to $to_email";
} catch (Exception $e) {
$error_message = "Failed to send email: {$mail->ErrorInfo}";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Email Test - SignEase</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-gray-100">
<div class="container mx-auto p-6">
<div class="bg-white rounded-lg shadow-md p-6 max-w-md mx-auto">
<h2 class="text-2xl font-bold mb-4">Test Email</h2>
<?php if (isset($success_message)): ?>
<div class="bg-green-100 border-l-4 border-green-500 text-green-700 p-4 mb-4">
<?php echo $success_message; ?>
</div>
<?php endif; ?>
<?php if (isset($error_message)): ?>
<div class="bg-red-100 border-l-4 border-red-500 text-red-700 p-4 mb-4">
<?php echo $error_message; ?>
</div>
<?php endif; ?>
<form method="post" class="space-y-4">
<div>
<label for="email" class="block text-sm font-medium text-gray-700">Email Address</label>
<input type="email" id="email" name="email" required
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm
focus:border-blue-500 focus:ring-blue-500">
</div>
<button type="submit" name="send_email"
class="w-full bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded">
Send Test Email
</button>
</form>
</div>
</div>
</body>
</html>