J' essaie d'envoyer un mail HTMl avec une pièce jointe. Malheureusement j' ai le message d'erreur suivant :
Warning: mail() [function.mail]: Permission denied: headers injection (empty line) in /home/www/f4e28b24b8dad49a90a589664765c79c/web/club/Test/mail.php on line 35
Mon code:
<?php
$to = '[email protected]' ;
// Sujet
$subject = " Inscription d'un nouveau membre du club";
$boundary='didondinaditondelosdudosdodudundodudindon';
//En-têtes du mail
$headers="From: [email protected]\r\n
MIME-Version: 1.0\r\n
Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n\n";
$body="--". $boundary ."\n
Content-Type: text/plain; charset=ISO-8859-1\r\n\n
Message principal du mail.\n\n";
$fichier=file_get_contents('./test.doc');
$fichier=chunk_split( base64_encode($fichier) );
//Écriture de la pièce jointe
$body = $body . "--" .$boundary. "\n
Content-Type: application/msword; name=\"nom_fichier\"\r\n
Content-Transfer-Encoding: base64\r\n
Content-Disposition: attachment; filename=\"nom_fichier\"\r\n\n
$fichier";
//Fermeture de la frontière
$body = $body . "--" . $boundary ."--";
//Envoi du mail
mail($to, $subject, $body, $headers);
?>
Est ce que c'est une erreur de permission ou de problème avec mon code ?Merci a celui qui pourra m'aider