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
|
<?php
/********************************
* Fonction d'envoi de Mail *
*******************************/
function Envoi_mail($from,$to,$subject,$message){
$eol="\n";
$hdr ='From: '.$from.$eol;
$hdr.='Return-Path: '.$from.$eol;
$hdr.='Reply-To: '.$from.$eol;
$hdr.='X-Priority: 3'.$eol;
$hdr.='X-Mailer: PHP/'.phpversion().$eol;
$hdr.='MIME-Version: 1.0'.$eol;
$hdr.='Content-Type: text/html; charset="ISO-8859-1"'.$eol;
$hdr.='Content-Transfer-Encoding: base64'.$eol.$eol;
$msg=chunk_split(base64_encode($message));
$obj='=?ISO-8859-1?B?'.base64_encode($subject).'?=';
return (bool)@mail($to,$obj,$msg,$hdr);
}
/********************************
* Initialisation des variables *
*******************************/
// Expediteur
$prenom ='Prénom';
$nom ='Nom';
$email ='xxxxxxxx@domaine.com';
$expediteur = $prenom.' '.$nom.' <'.$email.'>';
// Destinataire
$destinataire='yyyyyyyy@domaine.com';
// Sujet
$sujet='Test d\'envoi...';
// Message
$texte='Ceci est un Test...';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="fr">
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<p><strong>Informations</strong></p>
<dl>
<dt>Expediteur</dt>
<dd><?php echo htmlspecialchars($expediteur,ENT_QUOTES,'ISO-8859-1'); ?></dd>
<dt>Destinataire</dt>
<dd><?php echo htmlspecialchars($destinataire,ENT_QUOTES,'ISO-8859-1'); ?></dd>
<dt>Sujet</dt>
<dd><?php echo htmlspecialchars($sujet,ENT_QUOTES,'ISO-8859-1'); ?></dd>
</dl>
<p><strong>Contenu du message</strong></p>
<?php echo '<pre>'.htmlspecialchars($texte,ENT_QUOTES,'ISO-8859-1')."</pre>\n";
// Envoie le mail
if(Envoi_mail($expediteur,$destinataire,$sujet,$texte))
$message='Message envoyé';
else
$message='Erreur ! Le message n\'a pas été envoyé';
echo '<strong>'.$message."</strong>\n";
?>
</body>
</html> |
Partager