-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail_helper.php
More file actions
38 lines (28 loc) · 973 Bytes
/
mail_helper.php
File metadata and controls
38 lines (28 loc) · 973 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
35
36
37
38
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require __DIR__ . '/mailer/PHPMailer.php';
require __DIR__ . '/mailer/SMTP.php';
require __DIR__ . '/mailer/Exception.php';
function sendMail($to, $subject, $message) {
$mail = new PHPMailer(true);
try {
// SMTP CONFIG
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'ishrakhansocmacs@gmail.com'; // your Gmail
$mail->Password = 'dnkw godk neei dtic'; // app password
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
// EMAIL DETAILS
$mail->setFrom('ishrakhansocmacs@gmail.com', 'SOCMACS Portal');
$mail->addAddress($to);
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
return $mail->send();
} catch (Exception $e) {
return false;
}
}