-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail.php
More file actions
36 lines (31 loc) · 788 Bytes
/
mail.php
File metadata and controls
36 lines (31 loc) · 788 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
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'vendor/autoload.php';
function sendMail($to, $subject, $message)
{
$mail = new PHPMailer(true);
try {
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->IsHTML(true);
$mail->Username = "heyfreaker@gmail.com";
$mail->Password = "rormumkpjczsxesa";
$mail->SetFrom("heyfreaker@gmail.com");
$mail->Subject = $subject;
$mail->Body = $message;
$mail->AddAddress("$to");
if (!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
return false;
} else {
return true;
}
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
return false;
}
}