Mail-functie: mail versturen met html (table) in body
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?
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:
Excuus, hierbij de code:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?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);
?>
// 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);
?>
Gewijzigd op 26/09/2014 11:25:16 door Henk Jacobse
Ik heb een vergelijkbare situatie en heb dit in de message staan:
En dan misschien voor jou een andere charset waarde.
Code (php)
1
2
3
4
5
2
3
4
5
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>...</title>
</head>
..
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>...</title>
</head>
..
En dan misschien voor jou een andere charset waarde.
Gewijzigd op 26/09/2014 11:15:28 door Jan de Laet
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>
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>
De enige verschillen tussen wat jij doet en wat ik doe zijn:
en ik heb in de $headers wel de From staan.
en ik heb in de $headers wel de From staan.
Probleem gevonden.
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?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);
?>
// 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?
Ik zou graag een jpg-file in de html-body toevoegen.
Hoe kan ik dit doen?
Wil je die JPEG meesturen in de mail als attachment, of invoegen vanaf je website?
Het punt is dan wel dat deze vaak niet direct zichtbaaar zijn.
Het punt is dan wel dat deze vaak niet direct zichtbaaar zijn.




