Problème rendu HTML fonction mail()
Posté : 22 avr. 2015, 17:53
Bonjour,
je suis entrain de faire un petit script php en utilisant la fonction mail()...
Le rendu est bon sur les différentes boites emails que j'ai testé (free / outlook / hotmail) mais pas bon pour Gmail...
J'ai un rendu en text plutôt qu'en html...
Viici mon code :
Et voici le rendu Gmail :
Une idée ?
Merci
je suis entrain de faire un petit script php en utilisant la fonction mail()...
Le rendu est bon sur les différentes boites emails que j'ai testé (free / outlook / hotmail) mais pas bon pour Gmail...
J'ai un rendu en text plutôt qu'en html...
Viici mon code :
Code : Tout sélectionner
<?php
define('MAIL_DESTINATAIRE','[email protected]');
$sujet = 'Confirmation du bilan de santé '. $ad_nom .' - '. $ad_compagnie .' - '. $affiche_objet_dates .'.';
$boundary = md5(uniqid(rand()));
$mail_entete = "From: \"Bilan Santé Vitton\"<[email protected]> \n";
$mail_entete .= "Cc: [email protected] \n";
$mail_entete .= "Reply-To: [email protected] \n";
$mail_entete .= "MIME-Version: 1.0 \n";
$mail_entete .= "Content-Type: multipart/mixed; boundary=\"$boundary\" \n";
$mail_entete .= "\n";
$mail_corps = "--$boundary \n";
$mail_corps .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$mail_corps .= "Content-Transfer-Encoding: 8bit \n";
$mail_corps .= "\n";
$mail_corps .= '
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Template Mail | BSV</title>
<style type="text/css">
body {
background: #fff;
font-family: "Lucida Grande", "Trebuchet MS", sans-serif;
color: #292929;
font-size: 13px;
line-height: 1.2;
}
</style>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="font-family: "Lucida Grande", "Trebuchet MS", sans-serif; background: #fff; font-size: 13px; color: #292929; line-height: 1.2; border: #a69f8f 1px solid;">
<tbody>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td width="20"> </td>
<td width="560" valign="top">Bonjour,<br /><br />
</table>
</body>
</html>';
$mail_corps .= "\n";
foreach($_FILES['_fichiermailpdf']['name'] as $file => $key) {
$_fichiermailpdf['name'] = $_FILES['_fichiermailpdf']['name'][$file];
$_fichiermailpdf['type'] = $_FILES['_fichiermailpdf']['type'][$file];
$_fichiermailpdf ['size'] = $_FILES['_fichiermailpdf']['size'][$file];
$_fichiermailpdf['tmp_name'] = $_FILES['_fichiermailpdf']['tmp_name'][$file];
if(!empty($_fichiermailpdf['name'])) {
$file_name = cleanPdf($_fichiermailpdf['name']);
$data_file_name = chunk_split(base64_encode(file_get_contents($_fichiermailpdf['tmp_name'])));
$mail_corps .= "--$boundary \n";
$mail_corps .= "Content-Type: application/pdf; name=\"$file_name\" \n";
$mail_corps .= "Content-Transfer-Encoding: base64 \n";
$mail_corps .= "Content-Disposition: attachment; filename=\"$file_name\" \n";
$mail_corps .= "\n";
$mail_corps .= $data_file_name."\n";
$mail_corps .= "\n";
}
}
$mail_corps .= "--$boundary--";
if(mail(MAIL_DESTINATAIRE,utf8d($sujet),utf8d($mail_corps),utf8d($mail_entete))) {
echo '<div class="alert mt20 success">Mail envoyé avec succès au client.</div>';
} else {
echo '<div class="alert mt20 error">Message could not be sent.</div>';
}
?>
Code : Tout sélectionner
--fc8e072da5efd1dec8cab674a49ecec6
Content-type: text/html; charset="utf-8"
Content-Transfer-Encoding: 7bit
<html>
<head>
</head>
<body style="font-family: "Lucida Grande", "Trebuchet MS", sans-serif; background: #fff; font-size: 13px; color: #292929; line-height: 1.2;">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" style="border: #a69f8f 1px solid;">
<tbody>
<tr>
<td colspan="3"> </td>
</tr>
<tr>
<td width="20"> </td>
<td width="560" valign="top">Bonjour,<br /><br />
Merci