Failed To Connect To Mailserver At "localhost" Port 25
5 replies to this topic
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.
Posted 04 January 2012 - 09:58 AM
If your internet provider requires a userid/password for sending email (and most do) then plain WAMP won't work for you. XAMPP contains a mail server program. Most people find it easier to just use one of the low-cost site hosting servers for php/mysql learning. See:
Posted 04 January 2012 - 10:20 AM
XAMPP? is this a program like WAMP?
back when i was taking a php class in college we had an exercise similar to this and the mail() function worked fine using MAMP on my macbook pro.
Posted 04 January 2012 - 10:32 AM
You were using MAMP Pro, which also contains a mail server. WAMP does not.
Posted 04 January 2012 - 01:50 PM
on the subject of MAMP.. i just got home from work dealing with this issue all day.. not to mention that WAMP wont allow me into myphpadmin panel.. (another issue altogether)
anyhow.. i get home, fire up my macbook, fire up MAMP and ran the script. Everything is working fine, no line errors... however i didnt get the email in my inbox for the email address that i assigned to send in php script. So not sure why the email didnt come through, but at least i didnt get that mail() function on port 25 error.
Thanks for you speedy replies by the way.
Posted 04 January 2012 - 09:31 PM
Don't have a Mac and never used MAMP so can't help you on that one.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users