I trying to add a PHP contact form to my web site where an user can send an email from the form and send it to a friend.
very basic at the moment just to get it to work but on my Apache server when I run the script I get the message.
Warning: mail(): SMTP server response: 503 No valid recipients specified. in C:\xampp\htdocs\date\testmeil.php on line 12
refer to this line of code: $ok = mail($to, $subject,$message, $headers );
The PHP script seem to me that it is running before I get a chance to fill out the form. There is a problem in the PHP script as the mercury mail service has not received a message from the php script.
I have a Test web domain which I up loaded to that thinking it might been just my email and php server having a hissy fit but still not luck soon as it loaded and had a chance to fill out the contact form I had a message as the top of the page say email sent ok and I done nothing other then load the page.
Can someone tell me where or what I am doing wrong.
[php]<?php
$to = $_POST['emailto'];
$from = $_POST['emailfrom'];
$subject = $_POST['subject'];
$comments = $_POST['comments'];
$message = " this is a test and this is what you have entered" .$comments;
$headers ="from:".$from ;
$ok = mail($to, $subject,$message, $headers );
if($ok) echo "sent fine";
else echo" not sent fine";
?>[/php]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<form action="sent.html" method="post">
TO <input type="text" name="emailto" value="yourname@yourdomain" /><br />
FROM<input type="text" name="emailfrom" /><br />
SUBJEC<input type="subject" name="subject" /><br />
MESSAGE <textarea name="comments"></textarea><br />
<input type="submit" name="submit" />
<body>
</body>
</html>