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
| <?php
// To
$to = 'moi@hotmail.fr';
// Subject
$subject = 'Lettre';
// clé aléatoire de limite
$boundary = md5(uniqid(microtime(), TRUE));
// Headers
$headers = "From: Moi<moi@hotmail.fr>"."\r\n";
$headers .= 'Mime-Version: 1.0'."\r\n";
$headers .= 'Content-Type: multipart/mixed;boundary='.$boundary."\r\n";
$headers .= "\r\n";
// Message
$msg = 'Texte affiché par des clients mail ne supportant pas le type MIME.'."\r\n\r\n";
// Message HTML
$msg .= '--'.$boundary."\r\n";
$msg .= 'Content-type: text/html; charset=utf-8'."\r\n\r\n";
$msg .= '
bla bla bla jusque là tout marche
<textarea name="autresInfos" cols="50" rows="7"></textarea>
'."\r\n";
// Pièce jointe 1
/*$file_name = 'monfichier.pdf';
if (file_exists($file_name))
{
$file_type = filetype($file_name);
$file_size = filesize($file_name);
$handle = fopen($file_name, 'r') or die('File '.$file_name.'can t be open');
$content = fread($handle, $file_size);
$content = chunk_split(base64_encode($content));
$f = fclose($handle);
$msg .= '--'.$boundary."\r\n";
$msg .= 'Content-type:'.$file_type.';name='.$file_name."\r\n";
$msg .= 'Content-transfer-encoding:base64'."\r\n\r\n";
$msg .= $content."\r\n";
}*/
// Fin
$msg .= '--'.$boundary."\r\n";
// Function mail()
if (mail($to, $subject, $msg, $headers))
echo "Mail envoyé";
else
echo "erreur lors de l'envoi";
?> |
Partager