This question already has an answer here:
I am trying to put breaks on my mail script. Because now I receive all the information in just one line. I have searched for and stuff but that doesnt work :(
Anyone suggestions? Would be of real help. THnx!
<?php
if($_POST){
$vorm = $_POST['vorm'];
$rente = $_POST['rente'];
$einde = $_POST['einde'];
$waarde = $_POST['waarde'];
$leen = $_POST['leen'];
$aanhef = $_POST['aanhef'];
$voornaam = $_POST['voornaam'];
$achternaam = $_POST['achternaam'];
$postcode = $_POST['postcode'];
$telefoon = $_POST['telefoon'];
$email = $_POST['email'];
$message = $_POST['form_msg'];
mail("m.bosch@unit-ict.nl", "Hypotheek aanvraag", $vorm .$rente .$einde .$waarde .$leen .$aanhef .$voornaam .$achternaam .$postcode .$telefoon .$email .$message);
}
</div>
Certainly such line breaks will work in email messages. Most likely you applied them wrong somehow. Here is a working example:
<?php
// [...]
mail(
"m.bosch@unit-ict.nl",
"Hypotheek aanvraag",
sprintf("vorm: %s
rente: %s
einde: %s
waarde: %s
leen: %s
aanhef: %s
voornaam: %s
achternaam: %s
postcode: %s
telefoon: %s
email: %s
message:
%s",
$vorm .$rente .$einde .$waarde .$leen .$aanhef .$voornaam .$achternaam .$postcode .$telefoon .$email .$message);
);
Also using heredoc
notation would be a very elegant approach:
<?php
// [...]
$content = <<< EOT
vorm: {$vorm}
rente: {$rente}
einde: {$einde}
waarde: {$waarde}
leen: {$leen}
aanhef: {$aanhef}
voornaam: {$voornaam}
achternaam: {$achternaam}
postcode: {$postcode}
telefoon: {$telefoon}
email: {$email}
message:
{$message}
EOT;
mail("m.bosch@unit-ict.nl", "Hypotheek aanvraag", $content);
Note that this will create an empty line between each line on most situation, but you are on the safe side like that. The issue here is that MS-Windows based systems (as often) do things different that defined in all standards.
You could try the following:
<?php
$vorm = strip_tags( $_POST['vorm'] );
$rente = strip_tags( $_POST['rente'] );
$einde = strip_tags( $_POST['einde'] );
$waarde = strip_tags( $_POST['waarde'] );
$leen = strip_tags( $_POST['leen'] );
$aanhef = strip_tags( $_POST['aanhef'] );
$voornaam = strip_tags( $_POST['voornaam'] );
$achternaam = strip_tags( $_POST['achternaam'] );
$postcode = strip_tags( $_POST['postcode'] );
$telefoon = strip_tags( $_POST['telefoon'] );
$email = strip_tags( $_POST['email'] );
$message = strip_tags( $_POST['form_msg'] );
$naar = "m.bosch@unit-ict.nl";
$onderwerp = "Hypotheek aanvraag";
$bericht =
"
Vorm: {$vorm}
Rente: {$rente}
Einde: {$einde}
Waarde: {$waarde}
Leen: {$leen}
Aanhef: {$aanhef}
Voornaam: {$voornaam}
Achternaam: {$achternaam}
Postcode: {$postcode}
Telefoon: {$telefoon}
Email: {$email}
Bericht: {$message}
";
$headers = "From: yourname example@example.com";
mail($naar, $onderwerp, $bericht, $headers);
email()
strip_tags()
Prevent HTML tags from being send