php script not working

Problems with the Windows version of XAMPP, questions, comments, and anything related.

php script not working

Postby meursault » 05. August 2010 22:24

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 :-)
Posts: 1
Joined: 05. August 2010 21:45

Re: php script not working

Postby Altrea » 06. August 2010 06:54

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
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
AF Moderator
Posts: 10443
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 10 Pro x64

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 67 guests