-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendMail.php
44 lines (41 loc) · 1.42 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
43
44
<?php
$mailFrom = $_POST['mail'];
$mailFromName = 'Contact - Enfants du web';
$mailSubject = 'Proposition - Enfants du web';
$mailMessage = stripslashes($_POST['body']);
$sujet = $mailSubject;
$strTo = '[email protected]';
$strHeader = 'MIME-Version: 1.0' . "\r\n";
$strHeader .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
$strHeader .= "From: ".$mailFromName." <".$mailFrom.">" . "\r\n";
$strHeaders .= "Reply-To: ".$mailFrom."\r\n"."X-Mailer: PHP/".phpversion();
$message = "
<html>
<head>
<meta charset='utf-8'>
<title>
Proposition de projet
</title>
</head>
<body>
<h2>
Proposition de projet
</h2>
<b>Mail de l'emetteur</b> : ".$_POST['mail']."
<br>
<br>
<b>Message :</b>
<br>
".$mailMessage."
</body>
</html>
";
if (mail($strTo,$sujet,$message,$strHeader)) {
$data = array('success' => true, 'message' => 'Merci ! Votre mail a bien été envoyé !', 'mail' => $message);
echo json_encode($data);
} else {
$data = array('success' => false, 'message' => 'Une erreur est survenue, le mail n\'a pas pu être envoyé');
echo json_encode($data);
exit;
}
?>