par
obencia » 15 juil. 2009, 15:57
Je comprends pas où mettre le code
Code : Tout sélectionner
// To
$to = '[email protected]';
// Subject
$subject = 'Developpez.com - Test Mail';
// clé aléatoire de limite
$boundary = md5(uniqid(microtime(), TRUE));
// Headers
$headers = 'From: Adrien Pellegrini <[email protected]>'."\r\n";
$headers .= 'Mime-Version: 1.0'."\r\n";
$headers .= 'Content-Type: multipart/mixed;boundary='.$boundary."\r\n";
$headers .= "\r\n";
// Message
$msg = 'This is a multipart/mixed message.'."\r\n\r\n";
// Texte
$msg .= '--'.$boundary."\r\n";
$msg .= 'Content-type:text/plain;charset=utf-8'."\r\n";
$msg .= 'Content-transfer-encoding:8bit'."\r\n";
$msg .= 'Un message avec une pièce jointe.'."\r\n";
// Pièce jointe
$file_name = 'image.jpg';
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";
$msg .= $content."\r\n";
}
// Fin
$msg .= '--'.$boundary."\r\n";
// Function mail()
mail($to, $subject, $msg, $headers);
Je comprends pas où mettre le code
[code]
// To
$to = '
[email protected]';
// Subject
$subject = 'Developpez.com - Test Mail';
// clé aléatoire de limite
$boundary = md5(uniqid(microtime(), TRUE));
// Headers
$headers = 'From: Adrien Pellegrini <
[email protected]>'."\r\n";
$headers .= 'Mime-Version: 1.0'."\r\n";
$headers .= 'Content-Type: multipart/mixed;boundary='.$boundary."\r\n";
$headers .= "\r\n";
// Message
$msg = 'This is a multipart/mixed message.'."\r\n\r\n";
// Texte
$msg .= '--'.$boundary."\r\n";
$msg .= 'Content-type:text/plain;charset=utf-8'."\r\n";
$msg .= 'Content-transfer-encoding:8bit'."\r\n";
$msg .= 'Un message avec une pièce jointe.'."\r\n";
// Pièce jointe
$file_name = 'image.jpg';
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";
$msg .= $content."\r\n";
}
// Fin
$msg .= '--'.$boundary."\r\n";
// Function mail()
mail($to, $subject, $msg, $headers);
[/code]