Page 1 sur 1

Notification par email

Posté : 14 juil. 2010, 23:35
par patrickg77
Bonjour,

J'ai script récupérer pour l'insertion de commentaire, je cherche à faire que quand quelqu' un post un commentaire, je recois un email.

Le problème c'est que je sais pas trop comment faire....

Voici mon bout de code :

Code : Tout sélectionner

<form action="commentaire.<?php echo $php_extension; ?>" method="post" name="commentaire" onsubmit="return verif_form()"> <b><?php echo $str_nom; ?> :</b></td> <td><input name="_recipients" type="hidden" value="mon email"><input type="text" name="auteur_form" value="<?php if ($cookie && $t_cookie[0] != '' && $action != 'ajouter') echo htmlspecialchars($t_cookie[0]); else echo htmlspecialchars($auteur_form); ?>" size=18 maxlength=14></td> </tr> <tr> <td><?php echo $str_email; ?> :</td> <td><input type="text" name="email_form" value="<?php if ($cookie && $t_cookie[1] != '' && $action != 'ajouter') echo $t_cookie[1]; else echo $email_form; ?>" size=18 maxlength=40></td> </tr> <tr> <td colspan=2><b><?php echo $str_commentaire; ?> :</b><br><textarea name="texte_form" cols=29 rows=5></textarea></td> </tr> <tr> <td align="center" colspan=2><input type="hidden" name="nom" value="<?php echo htmlspecialchars($nom); ?>"><input type="hidden" name="action" value="ajouter"><input type="submit" value="<?php echo $str_ajouter; ?>">
j'avais fais comme ca mais c'est pas bon...

Merci pour votre aide

Re: Notification par email

Posté : 02 août 2010, 11:16
par BaLiSTiK
Pour envoyer des mails, il y a en PHP la fonction mail() qui prend comme parametres dans l'ordre :
- Le destinataire
- Sujet du mail
- Le message
- Headers (optionnel)

Donc, dans ta page ou tu envoie les données de ton formulaire, ça doit donner un truc comme ça :
$dest = '[email protected]';
$subject = 'Envoie de mail de test';
$msg = 'Nouveau commentaire';

if(mail($dest, $sibject, $msg)){
	echo 'Mail envoy&eacute;';	
}else{
	echo 'Probleme d envoi de mail';	
}
Sur al doc tu devrais trouver plus de détails :)
http://fr.php.net/manual/fr/function.mail.php