Question

This what I have I tried to put it in a table just like:

<table>
<tr><td>$_POST['onderwerp']</td></tr>
</table>

This is what I have it sends the mail but it's to messy:

<?php

$to      = 'example@gmail.com';

$subject = 'Vraag via de website';

$message = 'Onderwerp:'. $_POST['onderwerp'].'<br /><br />'.$_POST['vraag'].'<br /><br />'.'Telefoonummer:'. $_POST['tel'].'<br /><br />'.'Email:'. $_POST['email'] ;



$headers  = 'MIME-Version: 1.0' . "\r\n";

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



// Additional headers

$headers .= 'To:<eexample@gmail.com>' . "\r\n";

$headers .= 'The shop<example@gmail.com>' . "\r\n";





mail($to, $subject, $message, $headers);

header('Location: contact.html');

?>

I just want to send the variables in a table so that I don't have to search through all the text.

Was it helpful?

Solution

<?php
$to = 'user@example.com';
$subject = 'Vraag via de website';
$msg = "<html>
 <head>
 <title>Title of email</title>
 </head>

 <body>

<table cellspacing=\"4\" cellpadding=\"4\" border=\"1\" align=\"center\">

<tr>
<td align=\"center\">Onderwerp</td>
<td align=\"center\"> vraag</td>
<td align=\"center\">Telefoonummer</td>
<td align=\"center\">Email</td>
</tr>

<tr>
<td align=\"center\">".$_POST['onderwerp']."</td>
<td align=\"center\">".$_POST['vraag']."</td>
<td align=\"center\">".$_POST['tel']."</td>
<td align=\"center\">".$_POST['email']."</td>
</tr>



</table>
</body>
</html>";

// Make sure to escape quotes

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: My Site Name <me@mysite.com>' . "\r\n";

mail($to, $subject, $msg, $headers);

?> 

OTHER TIPS

you could try this using your variables.

$var = 'test';
$var2 = 'test2';

echo '<table border="1">';
echo '<tr><td>' . $var . '</td></tr>';
echo '<tr><td>' . $var . '</td></tr>';
echo '</table>';

this will show the variables in a table, then you can edit the table using css how you want. :)

I suggest that you include swiftmailer. Swiftmailer makes sure emails get delivered in the Inbox and you can easily include HTML markup in your emails:

Swiftmailer HTML in email

Just download the Swiftmailer Library, include and configure it like this example:

Sending an email in swiftmailer

Let me know if this helps you out!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top