Informations :
Dates
- Publish : : 2010
- Modification : Thursday 01 september 2011
- 3715 views
Share :
Script avec 160 lignes
001[php]
002if($_POST) {
003 004$title = explode(' < ', $this→page['out']['title']);
005$title = array_reverse($title);
006 007 008if( !empty($_POST['nom']) && !empty($_POST['email']) && !empty($_POST['message']) ) {
009 010011
# Config
012 013$formulaire['select'][1]['titre'] = $title[2].' > '.$title[1];
014$formulaire['select'][1]['email'][0] = 'email_1@domaine.tld';
015$formulaire['select'][1]['email'][1] = 'email_2@domaine.tld';
016 017 018019
$date = mktime(0, 0, 0, substr(date("Y-m-d"),5,2), substr(date("Y-m-d"),8,2), substr(date("Y-m-d"),0,4));
020$date = date("d",$date)."/".date("m",$date)."/".date("Y");
021$heure = date("Hhi");
022023
$post_civilite = $_POST['civilite'];
024$post_nom = $_POST['nom'];
025$post_prenom = $_POST['prenom'];
026$post_email = $_POST['email'];
027028
$post_message = $_POST['message'];
029 030if($post_email != '') {
031//$type_contact = $formulaire['select'][1]['titre'];
032foreach($formulaire['select'][1]['email'] as $email) {
033$destinaires.= $email.',';
034}
035}
036 037$subject = 'Titre mail : ';
038$subject .= $formulaire['select'][1]['titre'];
039 040//-----------------------------------------------
041//MESSAGE TEXTE
042//-----------------------------------------------
043044
$message_text = ''.$subject.''."n";
045046
$message_text.= '' . "n";
047$message_text.= $post_message."n";
048$message_text.= '' . "n";
049 050$message_text.= '' . "n";
051052
$message_text.= 'Identification de l'internaute' . "n";
053054
$message_text.= ''."n";
055$message_text.= '* Prénom Nom : '.$post_civilite.' '.$post_prenom.' '.$post_nom.'' . "n";
056$message_text.= '* Email : '.$post_email.''."n";
057058
if(isset($_SERVER["HTTP_X_USER_AGENT"]) )
059$message_text.= '* Navigateur : '.$_SERVER["HTTP_X_USER_AGENT"].'' . "n";
060else
061$message_text.= '* Navigateur : '.$_SERVER["HTTP_USER_AGENT"].'' . "n";
062 063if(isset($_SERVER["HTTP_X_USER_AGENT"]) )
064$message_text.= '* IP : '.$_SERVER["HTTP_X_FORWARDED_IP"].'' . "n";
065else
066$message_text.= '* IP : '.$_SERVER["REMOTE_ADDR"].'' . "n";
067 068if(isset($_SERVER["HTTP_VIA"]) )
069$message_text.= '* IP VIA : '.$_SERVER["HTTP_VIA"].'' . "n";
070071
$message_text.= '* Date : '.$date.' - '.$heure.'' . "n";
072$message_text.= '' . "n";
073 074//-----------------------------------------------
075//MESSAGE HTML
076//-----------------------------------------------
077078
$message_html = '<h2>'.$subject.'</h2>'."n";
079080
$message_html.= '<p>'."n";
081$message_html.= $post_message."n";
082$message_html.= '</p>'."n";
083 084$message_html.= '<hr />'."n";
085086
$message_html.= '<h3>Identification de l'internaute/h3>'."n";
087088
$message_html.= '<ul>'."n";
089$message_html.= ' <li>Prénom Nom : '.$post_civilite.' '.$post_prenom.' '.$post_nom.''."n";
090$message_html.= ' <li>Email : <a href="mailto:'.$post_email.'">'.$post_email.'</a>'."n";
091092
if(isset($_SERVER["HTTP_X_USER_AGENT"]) )
093$message_html.= ' <li>Navigateur : '.$_SERVER["HTTP_X_USER_AGENT"].''."n";
094else
095$message_html.= ' <li>Navigateur : '.$_SERVER["HTTP_USER_AGENT"].''."n";
096 097if(isset($_SERVER["HTTP_X_USER_AGENT"]) )
098$message_html.= ' <li>IP : '.$_SERVER["HTTP_X_FORWARDED_IP"].''."n";
099else
100$message_html.= ' <li>IP : '.$_SERVER["REMOTE_ADDR"].''."n";
101 102if(isset($_SERVER["HTTP_VIA"]) )
103$message_html.= ' <li>IP VIA : '.$_SERVER["HTTP_VIA"].''."n";
104105
$message_html.= ' <li>Date : '.$date.' - '.$heure.''."n";
106$message_html.= '</ul>'."n";
107 108 109//-----------------------------------------------
110//GENERE LA FRONTIERE DU MAIL ENTRE TEXTE ET HTML
111//-----------------------------------------------
112113
$frontiere = '-----=' . md5(uniqid(mt_rand()));
114115
//-----------------------------------------------
116//HEADERS DU MAIL
117//-----------------------------------------------
118119
$headers = 'From: "'.$post_nom.' '.$post_prenom.'" <'.$post_email.'>' . "rn";
120//$headers = 'From: '.$post_email.'' . "rn" .
121$headers .= 'Return-Path: <'.$post_email.'>' . "rn";
122$headers .= 'X-Mailer: PHP/' . phpversion() . "rn";
123$headers .= 'MIME-Version: 1.0' . "rn";
124$headers .= 'Content-Type: multipart/alternative; boundary="'.$frontiere.'"' . "rn";
125$headers .= 'Content-Type: text/html; charset="iso-8859-1"' . "rn";
126127 128
//-----------------------------------------------
129//MESSAGE TEXTE
130//-----------------------------------------------
131132
$message = 'This is a multi-part message in MIME format.' . "nn";
133$message .= '--'.$frontiere.'' . "n";
134$message .= 'Content-Type: text/plain; charset="iso-8859-1"' . "n";
135$message .= 'Content-Transfer-Encoding: 7bit' . "nn";
136$message .= addslashes(stripslashes($message_text))."nn";
137138
//-----------------------------------------------
139//MESSAGE HTML
140//-----------------------------------------------
141142
$message .= '--'.$frontiere.'' . "n";
143$message .= 'Content-Type: text/html; charset="iso-8859-1"'."n";
144$message .= 'Content-Transfer-Encoding: quoted-printable'."nn";
145$message .= addslashes(stripslashes($message_html))."nn";
146147
$message .= '--'.$frontiere.'--' . "n";
148149
//-----------------------------------------------
150 151 152if( mail($destinaires, $subject, $message, $headers) ) {
153echo 'Votre message a bien été envoyé...';
154} else {
155echo 'Votre message n'a pas été envoyé !';
156}
157158
159
}
160} [/php]