Salam
J'ai programmé un formulaire en php par ce code :
Mais après l'hébergement de notre site, une erreur est affichée.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107 <?php if (isset($_POST['send']) && $_POST['send'] == 'Envoyer') { if ((isset($_POST['destinataire']) && !empty($_POST['destinataire']))) { if (preg_match('#^[\w.-]+@[\w.-]+\.[a-z]{2,6}$#i', $_POST['destinataire'])) { $destinataire = $_POST['destinataire']; $objet = $_POST['objet']; if (isset($_POST['message']) && empty($_POST['message'])) { $message = " "; } else { $message = $_POST['message']; } require_once ('PHPMailer/class.phpmailer.php'); include ("PHPMailer/class.smtp.php"); // Création d'un nouvel objet $mail $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "smtp.gmail.com"; $mail->From = $destinataire; $mail->FromName = $objet . " " . $destinataire; $mail->SMTPSecure = "tls"; $mail->AddAddress("******@gmail.com"); $mail->SMTPAuth = "true"; $mail->Username = "****@gmail.com"; $mail->Password = "******"; $mail->Port = "587"; /*$mail->Subject = $objet; */ $mail->Body = $message; if (!$mail->Send()) { echo 'Message was not sent.'; echo 'Mailer error: ' . $mail->ErrorInfo; } else { echo '<script type="text/javascript">' . 'alert("Votre message a été envoyer");' . 'document.location.href=history.back(-1);' . '</script>'; } } else { $erreur = "Le format d'adresse Email est incorrect."; } } else if (empty($_POST['destinataire'])) { $erreur = "Entrer votre Email."; } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <body> <form method="post" name="contact1" > <div style=" margin-left:2%; color:#FF0000; position:relative " > <div align="left" ><span class="style1 style65"> <?php if (isset($erreur)) echo '<br />', $erreur; ?> </span></div> </div> <div align="left" style="postion:relative;margin-left:2%"> <p class="style65"><strong>Objet</strong></p> <p> <input style="postion:relative; width:90%; height:20px;" type="text" name="objet" id="objet" /> </p> </div> <div align="left" style="postion:relative;margin-left:2%"> <p class="style65"><strong>Email</strong></p> <p> <input type="text" name="destinataire" id="destinataire" style="width:90%; height:20px"/> </p> </div> <div align="left" style="postion:relative;margin-left:2%"> <p class="style65"><strong>Message</strong></p> <p> <textarea style=" width:90%; height:100px" name="message" id="message" rows="0" cols="0" class="required"></textarea> </p> </div> <div align="left"> <input style=" position:relative; font-weight:bold; margin-left:20%" type="reset" name="reset" id="reset" value="Réinitialiser" /> <input style=" position:relative; font-weight:bold; margin-left:20%" type="submit" name="send" id="send" value="Envoyer" /> </div> </form> </body> </html>
Je ne sais pas comment le régler.Mailer error: The following From address failed: ***@***: Called Mail() without being connected
Merci d'avance.
Partager