j'ai un petit problème...je ne parviens pas à envoyer un mail au format HTML via la fonction mail() de PHP.
J'ai pourtant suivit plusieurs tutos en ligne ainsi que passé en revue la doc PHP ...mais rien ne fonctionne !
Voici mon script :
$destinataire = 'info@monsite.com'; $objet = 'Test d\'envoi mail html'; $message = 'test message'; $name = 'nom@prenom.com'; $boundary = "---=_Part_".md5(uniqid(rand())); $headers = 'MIME-Version: 1.0'."\r\n"; $headers .= 'Content-Type: multipart/mixed; boundary="'.$boundary.'"'."\r\n"; $msg = 'This is a multi-part message in MIME format.'."\n"; $msg .= 'Ceci est un message est au format MIME.'."\n"; $msg .= "--".$boundary."\n"; $msg .= 'Content-Type: text/html; charset="iso-8859-1"'."\n"; $msg .= 'Content-Transfer-Encoding: quoted-printable'."\n"; $msg .= 'Content-Disposition: inline \n\n'; $msg .= '<html><head><title>Test mail html</title></head><body>'; $msg .= '<p>Bonjour,</p>'; $msg .= '<p>ce mail à été envoyé depuis <strong>Mon Site .com</strong> par '.$name.'</p>'; $msg .= '<p>****************************************</p>'; $msg .= '<p><strong>'.$message.'</strong></p>'; $msg .= '<p>****************************************</p>'; $msg .= '</body></html>'; $msg .= "\n\n--".$boundary."\n\n"; // envoi mail($destinataire,$objet,$msg,$headers);
Et le mail que je reçoit est comme ceci :
Content-Type: multipart/mixed; boundary="---=_Part_a535a7b9f85bcef35f46bc31849162bd" Message-Id: <20100131150508.14974133E3@60gp.ovh.net> Date: Sun, 31 Jan 2010 16:05:07 +0100 (CET) From: monsiteo@60gp.ovh.net (monsite) X-Ovh-Tracer-Id: 11251962194064415914 X-Ovh-Tracer-Id: 11251962195151658154 X-Ovh-Remote: 188.165.45.9 (50.mail-out.ovh.net) X-Ovh-Local: 213.186.33.29 (mx1.ovh.net) X-Spam-Check: DONE|U 0.5/N X-Antivirus: avast! (VPS 100130-1, 30/01/2010), Inbound message X-Antivirus-Status: Clean This is a multi-part message in MIME format. Ceci est un message est au format MIME. -----=_Part_a535a7b9f85bcef35f46bc31849162bd Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline \n\n<html><head><title>Test mail html</title></head><body><p>Bonjour,</p><p>ce mail à été envoyé depuis <strong>Mon Site .com</strong> par nom@prenom.com</p><p>****************************************</p><p><strong>test message</strong></p><p>****************************************</p></body></html> -----=_Part_a535a7b9f85bcef35f46bc31849162bd
Et comme vous pouvez le voir... ça n'a rien à voir avec un mail au format HTML...
Merci d'avance pour le coup de main ! ;)
