Hey all,
I have recently decided to pick up on PHP and after having finished a book with lessons, I decided to make a simple email-form as that was the only thing I couldn't get to work while doing the exercises stated in the book. (not even the script mentioned in the book worked)
Here's the problem; nothing gets mailed. I use a free webhost that uses php 4.3.4. I have read about the possibility of the host not supporting the mail function, but that post was about a year old so I'm wondering if that has changed?
While testing further, I tried it on localhost even though I've been told it wouldn't work in windows. I got this errormessage:
Warning: Failed to connect to mailserver, verify your "SMTP" setting in php.ini in c:\ibserver\www\comments.php on line 12
So on both localhost and webhost it failed. on the webhost it didn't even give an errormessage... it just didn't mail...
Here's the script I used:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?
if($submit)
{
mail("email@adress.nl", "$subject", "$comments", "$email");
}
else
{?>
<form method="post" action="comments.php">
//comments.php = the name of this script
E-Mail: <INPUT TYPE="TEXT" NAME="email" size=60>
Subject: <INPUT TYPE="TEXT" NAME="subject" size=60>
Comments: <TEXTAREA NAME="comments" ROWS=10 COLS=30></TEXTAREA>
<input type="submit" name="submit" value="submit">
</form>
<? }?>
</body>
</html>[/b]
Line 12 is as you would have probably guessed; the mail function.
Many tutorials state that mailing is as simple as it looks, but others say that you need to write more code behind the "$email", somewhat like:
<?php
mail("nobody@example.com", "the subject", $message,
"From: webmaster@{$SERVER['SERVER_NAME']}\r\n" .
"Reply-To: webmaster@{$SERVER['SERVER_NAME']}\r\n" .
"X-Mailer: PHP/" . phpversion());
?>
It's all abacadabra to me, so if someone could help me out here I would much appreciate it. Been working on this mail function (which 'should' be easy)for like a day or two now, and dunno what else to do๐
I hope I'm making sense here, if not just ask for I'll probably be around these forums like a hawk๐
Thanks in advance