Hai there,
I have doing php code for form data to be send to email.
But it is showing...
Quote:
Your message could not be sent at this time. Please try again.
Here is my code for html form...
-
<body>
-
-
<div id="emailform">
-
<form action="email-thankyou.php" method="post" name="contactForm" onsubmit="return validateForm(this);">
-
-
<p><strong>Name:</strong> <input name="name" type="text" size="40" /></p>
-
<p><strong>Email:</strong> <input name="email" type="text" size="40" /></p>
-
<p><strong>Message:</strong></p>
-
<p><textarea name="message" rows="4" cols="50"></textarea></p>
-
-
<div id="buttons"><input type="submit" value="Send Email"> <input type="reset" value="Reset"></div>
-
-
</form>
-
</div>
-
</body>
-
Here is my code for php file....
-
<?php
-
-
// Grab the form vars
-
$email = (isset($_POST['email'])) ? $_POST['email'] : '' ;
-
$message = (isset($_POST['message'])) ? $_POST['message'] : '' ;
-
$name = (isset($_POST['name'])) ? $_POST['name'] : '' ;
-
-
// Check for email injection
-
if (has_emailheaders($email)) {
-
die("Possible email injection occuring");
-
}
-
-
$sent = @mail("user@example.com", "Subject of the email ", "Name: $name\n Email: $email\n\n $message", "From: $email");
-
-
if ($sent ) {
-
echo "Thank you for your inquiry, Your message has been received. <br>We will get back to you as soon as we can.";
-
} else {
-
echo "Your message could not be sent at this time. Please try again.";
-
}
-
function has_emailheaders($text) {
-
return preg_match("/(%0A|%0D|\n+|\r+)(content-type:|to:|cc:|bcc:)/i", $text);
-
}
-
?>
-
Is it because im using yahoomail or gmail as a receiver's email.
Please help me....
Im a newbie in php coding.
Regards,
Meshack