Hi,

I have found a REALLY simple contact form, which i am trying to mail to my own email for testing.

But I havent tried this before so i am not sure how to set it up.

Hope someone can help me out!

I get this error:

( ! ) 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 C:\wamp\www\enkeltwebdesign\send_contact.php on line 21

I havent set up anything, so was kind of expecting it to go crazy when i submitted.

Can someone hint me on how to setup the mail function correct?

My code looks like this, just the core contact stuff, and processing which might be wrong too :-/

//The Form
<form name=\"form1\" method=\"post\" action=\"send_contact.php\">
<p>Emne:</p><input name=\"subject\" class=\"input\" type=\"text\" id=\"subject\" size=\"64\"><br /><br />
<p>Forespørgsel:</p><textarea name=\"detail\" cols=\"50\" rows=\"7\" id=\"detail\"></textarea><br /><br />
<p>Navn:</p><input name=\"name\" class=\"input\" type=\"text\" id=\"name\" size=\"64\"><br /><br />
<p>Email:</p><input name=\"customer_mail\" class=\"input\" type=\"text\" id=\"customer_mail\" size=\"64\"><br /><br />
<input type=\"submit\" name=\"Submit\" value=\"&nbsp;Send&nbsp;\"> <input type=\"reset\" name=\"Submit2\" value=\"&nbsp;Ryd formen&nbsp;\">

The form processing:

<?php
// Contact subject
$subject = $_POST['subject']; 
// Details
$message= $_POST['detail']; 

// Mail of sender
$mail_from= $_POST['customer_mail'];
// From 
$header="from: $name <$mail_from>"; // This is wrong I think? Undefined variable?

// Enter your email address
$to ='mail@mail.com';

$send_contact=mail($to,$subject,$message,$header); // This is wrong I think?

// Check, if message sent to your email 
// display message "We've recived your information"
if($send_contact){
echo "Tak for din forespørgsel.";
}
else {
echo "ERROR";
}
?>

No. The syntax of the mail() statement looks fine. The message you're getting indicates that smtp isn't set up or not working. You should contact your host about this.

Arh I see, thanks.

I am running on a localhost though. The site is not put online yet.

Is it not possible to tjeck locally, if it is working or not?

If you put this code in a file and run it, there will be information about smtp included in the output:

<?php
phpinfo();
?>

(I just did a quick "find" on the output on mine). If smtp isn't listed there at all, most likely it isn't enabled.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.