-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail.php
38 lines (33 loc) · 1.22 KB
/
mail.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
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Include PHPMailer files
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
function send_mail($recipient, $subject, $message)
{
$mail = new PHPMailer();
$mail->isSMTP();
// SMTP settings
$mail->SMTPDebug = 0; // Debugging off for production (use 2 for verbose debugging)
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->SMTPSecure = 'tls'; // Encryption type (use 'ssl' if required)
$mail->Port = 587; // SMTP port (use 465 for SSL)
$mail->Host = '...'; // SMTP server
$mail->Username = '...'; // Your full email address
$mail->Password = '...'; // E-mail Password (N.B. App Password for Gmail)
// Email settings
$mail->isHTML(true); // Send email in HTML format
$mail->addAddress($recipient, "User"); // Recipient's email and name
$mail->setFrom('....', '....'); // Sender's email and name
$mail->Subject = $subject; // Email subject
$mail->Body = $message; // Email content
// Send email and return status
if (!$mail->send()) {
return false;
} else {
return true;
}
}
?>