$variabel tonen in html email
Ik heb een html email voor mijn contact script. Als mensen nu een vraag stellen dan komt de tekst achter elkaar te staan zonder enters weer te geven. Hoe kan dit?
Het bovenstaande word als volgd getoond in de email: Beste Michiel, Hoe gaat het? Met vriendelijke groet,Harry
Alles achter elkaar en geen enters, Hoe kan dit?
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
//de vraag van de klant in een $variabel
$question = "Beste Michiel, <br /> Hoe gaat het? <br / > Met vriendelijke groet,<br /> Harry",
//stukje code uit html email
$message"
<tr>
<td align='left' style='padding: 2px; background-color: #ffffff; font-family: verdana, geneva, arial, helvetica, sans-serif; color: #000000; font-size: 10pt; font-weight: normal;'>
<div>$question</div>
</td>
</tr>";
?>
//de vraag van de klant in een $variabel
$question = "Beste Michiel, <br /> Hoe gaat het? <br / > Met vriendelijke groet,<br /> Harry",
//stukje code uit html email
$message"
<tr>
<td align='left' style='padding: 2px; background-color: #ffffff; font-family: verdana, geneva, arial, helvetica, sans-serif; color: #000000; font-size: 10pt; font-weight: normal;'>
<div>$question</div>
</td>
</tr>";
?>
Het bovenstaande word als volgd getoond in de email: Beste Michiel, Hoe gaat het? Met vriendelijke groet,Harry
Alles achter elkaar en geen enters, Hoe kan dit?
Omdat je mail blijkbaar geen html mail is.
http://phpwiki.santhe.nl/index.php/De_juiste_mailheaders
http://phpwiki.santhe.nl/index.php/De_juiste_mailheaders
Ik denk trouwens dat het toch ligt aan de <textarea></textarea>
Die geeft volgens mij geen geen html mee. Kan het daaraan liggen?
Die geeft volgens mij geen geen html mee. Kan het daaraan liggen?
nl2br().
Hoi Santhe,
Ik krijg inderdaad ook telkens \r\n tekens bij de teksten.
Misschien zijn het toch mij headers. Zie jij wat er verkeerd gaat?
Ik krijg inderdaad ook telkens \r\n tekens bij de teksten.
Misschien zijn het toch mij headers. Zie jij wat er verkeerd gaat?
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
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
<?php
# Setup mime boundary
$mime_boundary = 'Multipart_Boundary_x'.md5(time()).'x';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";
$headers .= "BCC: [email protected]\r\n";
$replyto .= "Reply-To: ".$websitename." <".$question_from_email.">\r\n";
$body = "This is a multi-part message in mime format.\n\n";
# Add in plain text version
$body.= "--$mime_boundary\n";
$body.= "Content-Type: text/plain; charset=\"charset=us-ascii\"\n";
$body.= "Content-Transfer-Encoding: 7bit\n\n";
$body.= $text_content;
$body.= "\n\n";
# Add in HTML version
$body.= "--$mime_boundary\n";
$body.= "Content-Type: text/html; charset=\"UTF-8\"\n";
$body.= "Content-Transfer-Encoding: 7bit\n\n";
$body.= $html_content;
$body.= "\n\n";
?>
# Setup mime boundary
$mime_boundary = 'Multipart_Boundary_x'.md5(time()).'x';
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\r\n";
$headers .= "Content-Transfer-Encoding: 7bit\r\n";
$headers .= "BCC: [email protected]\r\n";
$replyto .= "Reply-To: ".$websitename." <".$question_from_email.">\r\n";
$body = "This is a multi-part message in mime format.\n\n";
# Add in plain text version
$body.= "--$mime_boundary\n";
$body.= "Content-Type: text/plain; charset=\"charset=us-ascii\"\n";
$body.= "Content-Transfer-Encoding: 7bit\n\n";
$body.= $text_content;
$body.= "\n\n";
# Add in HTML version
$body.= "--$mime_boundary\n";
$body.= "Content-Type: text/html; charset=\"UTF-8\"\n";
$body.= "Content-Transfer-Encoding: 7bit\n\n";
$body.= $html_content;
$body.= "\n\n";
?>
Vergelijk het eens met het script achter de link die ik gaf.
Er zijn diverse verschillen te zien.
Er zijn diverse verschillen te zien.




