<input name="email" id="email" ..... >
if( $_POST['email'] && !preg_match( "/[\r\n]/", $_POST['email']) ) { $headers = "From: ".$_POST['email']; } else { $headers = "From: ".$youremail; }
if( $_POST['email'] && !preg_match( "/[\r\n]/", $_POST['email']) ) { $headers = "From: ".$_POST['email']; } else { $headers = "From: ".$youremail; }
Retourne TRUE si le mail a été accepté pour livraison, FALSE sinon.
Il est important de noter que ce n'est pas parce que le mail a été accepté pour livraison qu'il arrivera à destination.
$a = " Bonjour "; $b = " jdjo32"; echo $a.$b; //=> Va afficher : " Bonjour jdjo32 " echo " Bonjour ".$b; // => Va afficher : " Bonjour jdjo32 " echo " Bonjour $b"; // => Va afficher : " Bonjour $b "
// put your email address here $youremail = 'site@site.com'; // Récupération de l'émail passé en POST $email = isset($_POST['email'])?$_POST['email']:0; // prepare message $sujet = "Inscription Newsletter"; $body = "Inscription Newsletter : Email: ".$email; if( $email && !preg_match( "/[\r\n]/",$email ) ) { $headers = "From: ".$email; } else { $headers = "From: ".$youremail; } // *********** Envoie du mail ********************* //mail => Retourne TRUE si le mail a été accepté pour livraison, //FALSE sinon. if(mail($youremail, $sujet, $body, $headers )){ Echo " Mail envoyé "; }else{ Echo " Erreur."; } ?>
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question