-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend_email.php
More file actions
34 lines (29 loc) · 934 Bytes
/
send_email.php
File metadata and controls
34 lines (29 loc) · 934 Bytes
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
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php'; // Include PHPMailer
function sendEmail($to, $subject, $message) {
$mail = new PHPMailer(true);
try {
// SMTP Server Settings
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com'; // Change for Outlook, Yahoo, etc.
$mail->SMTPAuth = true;
$mail->Username = 'your-email@gmail.com'; // Your Email
$mail->Password = 'your-app-password'; // Use App Password
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
// Email Settings
$mail->setFrom('your-email@gmail.com', 'Admin Notification');
$mail->addAddress($to);
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
// Send Email
$mail->send();
return true;
} catch (Exception $e) {
return false;
}
}
?>