-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendMail.php
42 lines (35 loc) · 1.31 KB
/
sendMail.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
41
42
<?php
use PHPMailer\PHPMailer\PHPMailer;
if (isset($_POST['name']) && isset($_POST['email'])) {
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$body = $_POST['body'];
require_once "PHPMailer/PHPMailer.php";
require_once "PHPMailer/SMTP.php";
require_once "PHPMailer/Exception.php";
$mail = new PHPMailer();
//SMTP Settings
$mail->isSMTP();
$mail->Host = "smtp.gmail.com";
$mail->SMTPAuth = true;
$mail->Username = "prosantapaulbsmrstu@gmail.com"; //enter you email address
$mail->Password = 'prosantapaul842'; //enter you email password
$mail->Port = 465;
$mail->SMTPSecure = "ssl";
//Email Settings
$mail->isHTML(true);
$mail->setFrom($email, $name);
$mail->addAddress("prosantapaulbsmrstu@gmail.com"); //enter you email address
$mail->Subject = ("$email ($subject)");
$mail->Body = $body;
if ($mail->send()) {
$status = "success";
$response = "Email is sent!";
} else {
$status = "failed";
$response = "Something is wrong: <br><br>" . $mail->ErrorInfo;
}
exit(json_encode(array("status" => $status, "response" => $response)));
}
?>