Page 1 of 1

php script not working

PostPosted: 05. August 2010 22:24
by meursault
I have a php script:

Code: Select all
<?php $to = "altest2@localhost"; $subject = "Contact Us"; $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {print "Your mail was sent successfully"; } else {print "We encountered an error sending your mail"; } ?>


I'm trying to use this to send information entered on a form to [url]altest2@localhost[/url].

However, I keep getting error message:

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:\xampp\htdocs\formtest\contact.php on line 1
We encountered an error sending your mail

I'm new to XAMPP and PHP so any help would be greatly appreciated :-)

Re: php script not working

PostPosted: 06. August 2010 06:54
by Altrea
Well, everything which is important is in your error-message.

PHP can't connect your Mail-Server.
On Default there is no SMTP-Server configured in the php.ini.
You need a Mail-Server to send mails (most webhosts does have configured one).

XAMPP comes with Mercury as Testmailserver.
But its not easy to configure Mercury (beginners shouldn't try this)
And mails from private Mail_Servers will be filtered as Spam by the Mail-Services in the Internet