Ik wil graag een script maken waarin ik een html table in de body kan mailen.
Tal van voorbeelden gevonden maar krijg steeds de html code in de mail te zien ipv de tabel.

Hoe kan ik dit oplossen?
Zonder voorbeeld van je code, lastig te beantwoorden.
Ik denk dat je geen HTML-headers gebruikt in je mail-functie:

$headers.= 'MIME-Version: 1.0' . "\r\n";
$headers.= ('Content-type: text/html; charset=iso-8859-1' . "\r\n";
Excuus, hierbij de code:

<?php
// multiple recipients
$to = '[email protected]' . ', '; // note the comma
$to .= '[email protected]';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
//$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n";
//$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
//$headers .= 'Cc: [email protected]' . "\r\n";
//$headers .= 'Bcc: [email protected]' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>
Ik heb een vergelijkbare situatie en heb dit in de message staan:

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>...</title>
</head>
..


En dan misschien voor jou een andere charset waarde.
Helaas,

Krijg het volgende als mail binnen:

Content-type: text/html; charset=iso-8859-1


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Birthday Reminders for August</title> </head> <body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";


Hier vandaan
De enige verschillen tussen wat jij doet en wat ik doe zijn:


// message
$message = '<html>
...


en ik heb in de $headers wel de From staan.
Probleem gevonden.

<?php
// multiple recipients
$to = '[email protected]' . ', '; // note the comma
$to .= '[email protected]';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0
Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
//$headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n";
//$headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
//$headers .= 'Cc: [email protected]' . "\r\n";
//$headers .= 'Bcc: [email protected]' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);
?>
even een andere vraag als vervolg op het bovenstaande.

Ik zou graag een jpg-file in de html-body toevoegen.
Hoe kan ik dit doen?

Reageren