-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendEmail.php
47 lines (39 loc) · 1.37 KB
/
sendEmail.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
43
44
45
46
47
<?php
use PHPMailer\PHPMailer\PHPMailer;
if(isset($_POST['name']) && isset($_POST['email'])){
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$company = $_POST['company'];
$fonction = $_POST['fonction'];
$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 = "ayman@gmail.com"; //enter you email address
$mail->Password = 'ayman'; //enter you email password
$mail->Port = 465;
$mail->SMTPSecure = "ssl";
//email settings
$mail->isHTML(true);
$mail->setFrom($email, $name);
$mail->addAddress("ama@gmail.com");
$mail->Subject = ("Demande de Demo");
$mail->Body = "<br></br> Nom : ".$name." <br></br> Email : ".$email." <br></br>société : ".$company." <br></br> fonction : ".$fonction." <br></br>Numéro de Téléphone : ".$subject." <br></br>message : ".$body;
if($mail->send()){
$status = "success";
$response = "Email is sent!";
}
else
{
$status = "failed";
$response = "Something is wrong: <br>" . $mail->ErrorInfo;
}
exit(json_encode(array("status" => $status, "response" => $response)));
}
?>