How do I enable the PHP function mail()?

sk8tilubld

New member
I'm running a WAMP on my Windows XP OS (just in case you need to know). I want to know how I can use the mail() function using PHP. I have the code written out:

<?php
if (($_POST["sender_name"] == "") || ($_POST["sender_email"] == "") || ($_POST["message"] == "")) {
header("Location: simple_form.htm");
exit;
}

$msg = "E-mail sent from WWW SITE\n";
$msg .= "Sender's Name:\t$_POST[sender_name]\n\n";
$msg .= "Sender's E-mail:\t$_POST[sender_email]\n\n";
$msg .= "Message:\t$_POST[message]\n";

$to = "[email protected]";
$subject = "Website Feedback";
$mailheaders = "From: My Website <[email protected]>\n";
$mailheaders .= "Reply to: $_POST[sender_email]\n";

mail($to, $subject, $msg, $mailheaders);
?>

<html>
<head>
<title>Simple Feedback Form</title>
</head>

<body>
<h1>The following e-mail has been sent:</h1>
<p><strong>Your Name:</strong><br />
<? echo "$_POST[sender_name]"; ?></p>
<p><strong>Your E-mail:</strong><br />
<? echo "$_POST[sender_email]"; ?></p>
<p><strong>Message:</strong><br />
<? echo "$_POST[message]"; ?></p>
</body>
</html>

I tried it, but it gives me an error saying: Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in
php.ini or use ini_set() in http://127.0.0.1/PHP%20Test%20Site/send_simpleform.php
on line 17"

Help would be greatly appreciated. Maybe step by step instructions, if you have the time.

Thanks in advance.
I added

ini_set("SMTP", "smtp.byte.nl");
ini_set("smtp_port", "25");

but now I get this:

Warning: mail() [function.mail]: SMTP server response: 554 5.7.1 <[email protected]>: Relay access denied in C:\PHP Test Site\send_simpleform.php on line 20

Help please?
 
Back
Top