-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmail.php
executable file
·40 lines (32 loc) · 874 Bytes
/
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
39
40
<?php
require_once('config.php');
require_once('PHPMailer/src/PHPMailer.php');
require_once('PHPMailer/src/Exception.php');
require_once('PHPMailer/src/SMTP.php');
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
function SendMail(string $receiver, string $subject, string $content): bool {
$mail = new PHPMailer(true);
try {
$mail->isSMTP();
$mail->Host = SMTPAddress;
$mail->Port = SMTPPort;
$mail->SMTPAuth = true;
$mail->Username = SMTPUsername;
$mail->Password = SMTPPassword;
if (SMTPSSL) {
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
}
$mail->CharSet = PHPMailer::CHARSET_UTF8;
$mail->setFrom(SMTPUsername, Title);
$mail->addAddress($receiver);
$mail->isHTML(false);
$mail->Subject = $subject;
$mail->Body = $content;
$mail->send();
return true;
} catch (Throwable $e) {
return false;
}
}
?>