Hello all,
I am new to this forum and hope i have posted appropraite material for this section of the forum...here goes....
I have been training to become a web developer for 2 years now and can comfortably write in Perl and javascript as well as the obvious html xhtml css etc. I am now learning php and have come stuck at the first hurdle...
I am trying to create a simple web form using a sendmail.php file that emails the contant back to me (like a feedback form), according to the book i am learning from.
The Problem.
The script works the echo function correctly and displays the desired content and users input to the browser as it should, but the form itself is not being sent via as email as per my coding.
My PHP script is as follows........
Code: Select all
<!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>Sending mail from the form</title>
</head>
<body>
<?php
echo "<p>Thank You, <b>".$_POST["name"]."</b>, for your message!</p>";
echo "<p>Your email address is: <b>".$_POST["email"]."</b>.</p>";
echo "<p>Your message was:<br/>";
echo $_POST["message"]."</p>";
//start building the mail string
$msg = "Name: ".$_POST["name"]."\r\n";
$msg .= "E-Mail: ".$_POST["email"]."\r\n";
$msg .= "Message: ".$_POST["message"]."\r\n";
//set up the mail
$recipient = "root@xxxxxx.co.uk";
$subject = "Website Contact Form";
$mailheaders = "From: My Web Site <http://www.xxxxxx.co.uk> \r\n";
$mailheaders .= "Reply-To: ".$_POST["email"];
//Send the mail.
mail($recipient, $subject, $msg, $mailheaders);
?>
</body>
</html>Code: Select all
[mail function]
; For Win32 only.
SMTP = smtp.sky.com
smtp_port = 25
; For Win32 only.
;sendmail_from = website@xxxxxx.co.ukCode: Select all
<!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>E-mail Form</title>
</head>
<body>
<form action="sendmailnew.php" method="post">
<p><strong>Name: </strong><br>
<input type="text" name="name" size="25" /></p>
<p><strong>E-Mail Address: </strong><br/>
<input type="text" size="25" name="email" /> </p>
<p><strong>Message:</strong><br/>
<textarea name="message" cols="30" rows="5"></textarea></p>
<p><input type="submit" value="send" /></p>
</form>
</body>
</html>I have apache installed and am testing locally using http://localhost/[Mon Feb 04 14:20:07 2008] [error] [client 127.0.0.1] PHP Warning: mail() [<a href='function.mail'>function.mail</a>]: SMTP server response: 501 <My Web Site <http://www.thanweb.co.uk> >: "@" or "." expected after "My" in C:\\Program Files\\Apache Group\\Apache2\\htdocs\\sendmailnew.php on line 24, referer: http://localhost/feedback.html
I am running PHP vers 5.1.4
If anyone has ANY idea what may be causing this NOT to send the mail i would be very very grateful as my patience is wearing extremely thin now.
Thank you
Andrew
Everah | Please use appropriate code tags when posting code in the forums. Tags you can use are [code], [{LANG}] (where lang is the lowercase name of the language you are using) or [syntax="{LANG}"] (again, where language is the lowercase name of the language you are using). Thank you.