Voila le code que j'ai fais, a priori aucune faute dans le code
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
<?php
 
if($_POST['submit'])
{
 
$name= $_POST['name'];
$message = $_POST['message'];
 
if($name&&$message)
{
 
$namelenth = 20;
$messagelenth = 300;
 
if(strlen($name)<=$namelenth&&strlen($message)<=$messagelenth)
{
 
$to = "nicolas.h-69@hotmail.fr";
$subject = "Email from Nicolas";
$headers ="From: nicolas.h-69@hotmail.fr";
$body = "This is an email from $name\n\$message";
mail ($to,$subject,$body,$headers);
 
}
else
die("Max lenth for name is $namelenth and for messgae it's $messagelenth");
 
}
else
die("You must enter a name and message");
}
?>
 
 
<html>
 
<form action='sendanemail.php' method='POST'>
Name :<input type='text' name='name'maxlentegth='20'><br>
Message :<textarea name='message'></textarea><p>
<input type='submit' name='submit' value='Send to me this'>
</form>
 
 
</html>


Et voici le message d'erreur j'avoue que je n'ai pas compris

Code x : Sélectionner tout - Visualiser dans une fenêtre à part
Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\sendanemail.php  on line 22

Merci pour votre aide