Reputation: 2000
my php email script doesn't seem to be sending but I can't see why. Also I understand that there are certain security flaws with my script, any advice with that is much appreciated!
thank you
<?php
include('config.php');
$email1 = $_POST['email1'];
$id = $_POST['id'];
$fname = $_POST['fname'];
$firstname = $_POST['firstname'];
$surname = $_POST['surname'];
$to = '$email1';
$from = "$email";
$subject = "SC - You Have a Reply";
$body = "<html>
<body bgcolor=\"#FFFFFF\">
<center>
<b>Dear $firstname</b> <br>
<font color=\"red\">You have a response, regarding your Ad on StudentClutter!</font> <br>
<p> --------------------------------------------------------- </p>
<b> $fname </b>
<p> --------------------------------------------------------- </p>
<p> ".stripslashes($_POST['body'])." </p>
<br>
<br>
<br>
<p> You can reply to them by email: $emailadd </p>
<br>
<br>
<br>
<p>Thank you for using studentclutter.com </p>
<p> -- The Student Clutter Team </p>
</center>
</body>
</html>";
// To send the HTML mail we need to set the Content-type header.
$headers = "MIME-Version: 1.0rn";
$headers .= "Content-type: text/html; charset=iso-8859-1rn";
$headers .= "From: $from\r\n";
// now lets send the email.
mail($to, $subject, $body, $headers);
echo "Message has been sent!";
?>
Upvotes: 0
Views: 151
Reputation: 16948
You are using single quotes around $email1
, these are not necessary. Remove the quotes and it should work just fine.
Like this
$to = $email1;
I would advise you to check out the PHPMailer class, this class offers a whole range of features, along with security. It is very easy to use, just read through the documentation.
UPDATE
You have not escaped the return and new line special characters at the end of some of the headers. Change the end of the lines to look like this:
\r\n";
Upvotes: 1