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
|
$texte=$_POST['text'];
// Format : bool online_sendemail(string To, string Sujet, string Message[, int IsTxt]);
// IsTxt : 0 pour du html, 1 pour du texte (defaut)
// Exemple d'utilisation de 'email()' pour envoyer des mails en .html (ou en texte)
// Remplacer cette ligne par le domaine concernée.
// Il sera utilisé pour renvoyer les erreurs au postmaster de ce domaine
$Domain = preg_replace("/^[^\.]+\./", "", $_SERVER["SERVER_NAME"]);
function online_sendemail($To, $Subject, $Content, $Txt=1)
{
$email = $_POST['adresse'];
global $Domain;
$From= $Replyto=$email;
$Errors="postmaster@$Domain";
$Headers = "Return-path: $Errors\n";
if ($Txt != 1)
{
$Headers .= "Content-Type:text/html;charset=iso-8859-1\n";
$Headers .= "Content-Transfer-Encoding: 8bit\n";
}
return( email($From,$To,$Subject,$Content,$Replyto,$Headers));
}
// Exemple d'utilisation : On construit un fichier HTML minimal
// et on l'envoie au webmaster du domaine configuré plus haut.
$To = "webmaster@$Domain";
$Subject = "Test";
$Content = $texte;
$Txt = 0;
if (! online_sendemail($To, $Subject, $Content, $Txt))
{
print "le mail n'a pas ete envoye<br>";
}
else
{
print "Le mail a ete envoye<br>";
}
}
?> |
Partager