Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
80 lines (72 loc) · 2.79 KB
/
Copy pathindex.php
File metadata and controls
80 lines (72 loc) · 2.79 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require_once "vendor/autoload.php";
if (isset($_POST['name']) && isset($_POST['surname']) && isset($_POST['email']) && isset($_POST['message']))
{
$nom=$_POST['name'] ?? "";
$prenom=$_POST['surname'] ?? "";
$email=$_POST['email'] ?? "";
$message=$_POST['message'] ?? "";
}
if(empty($nom))
{
header("Location:index.html?error=Votre nom est requis");
exit();
}
else if (empty($prenom))
{
header("Location:index.html?error=Votre prenom est requis");
exit();
}
else if(empty($email))
{
header("Location:index.html?error=Votre adresse mail est requis");
exit();
}
else if(empty($message))
{
header("Location:index.html?error=un message est requis");
exit();
}
else{
$smtpHost = "smtp.gmail.com";
$smtpPort = 465;
$smtpUsername = "val59roger@gmail.com";
$smtpPassWord ="gudk iyiu pzes xneq";
$date = date('');
$mail = new PHPMailer(true);
try {
//Server settings
$mail->isSMTP();
$mail->Host = $smtpHost;
$mail->SMTPAuth = true;
$mail->Username = $smtpUsername;
$mail->Password = $smtpPassWord;
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->Port = $smtpPort;
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
$mail->setFrom('val59roger@gmail.com', 'Valentin Roger');
$mail->addReplyTo($email, "$nom $prenom");
$mail->addAddress('val59roger@gmail.com');
$mail->isHTML(true);
$mail->Subject = 'Prise de contact via portefolio';
$mail->Body = "<html>
<body>
<h1>$nom $prenom vient de prendre contact avec vous !</h1>
<p>$message</p>
<hr />
<p>envoie du mail le $date via $email<p>
</body>
</html>";
$mail->send();
header('Location: index.html');
exit();
} else {
header("Location:index.html?error=le mail est inconnue");
}
} catch (Exception $e) {
header("Location:index.html?error=erreur lors de l'envoie de mail : {$mail->ErrorInfo}");
}
}
?>