Posted 04 January 2012 - 09:27 AM
Im having problems getting the email to send to the target address. Here is the code from page 51, that appears to my eyes to be correct and no errors made, yet i get a error when submitting form, see below the code for the error that is generated.
code as follows:
<title>Aliens Abducted Me - Report an Abduction</title>
<h2>Aliens Abducted Me - Report an Abduction</h2>
$name = $_POST['firstname'] . ' ' . $_POST['lastname'];
$to = 'email@example.com';
$subject = 'Aliens Abducted Me - Abduction Report';
$msg = "$name was abducted $when_it_happened and was gone for $how_long. \n" .
"Number of aliens: $how_many\n" .
"Alien description: $alien_description\n" .
"What they did: $what_they_did\n" .
"Fang spotted: $fang_spotted\n" .
"Other comments: $other";
mail($to, $subject, $msg, 'From:' . $email);
echo 'Thanks for sumbitting the form.<br/>';
echo 'You were abducted ' . $when_it_happened;
echo ' and were gone for ' . $how_long.'<br/>';
echo 'Number of aliens: ' . $how_many.'<br/>';
echo 'Describe them: ' . $alien_description.'<br/>';
echo 'The aliens did this: ' . $what_they_did.'<br/>';
echo 'Was Fang there? ' . $fang_spotted.'<br/>';
echo 'Other comments: ' . $other.'<br/>';
echo 'Your email address is ' .$email;
Error received when submitting the form:
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\Testsite\report.php on line 27
I'm running WAMP as a local server, i looked in the php.ini files there are 2, and it appears that the smtp settings and port are set correctly and to port 25.