Php error in runtime

Hey there guys this is sai krishna,

Recently my system got reset. So my xampp got uninstalled. next installed my os and also xampp.

When i am running code here i am getting this error every time…Please help me…

Warning: 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\xampp\ajs.php on line 36

This is the code at line no 36

36 : if(mail($to, $subject, $message, $headers)){
37 : header(‘Location: www.google.com’);
38 :
39 : }else{
40 : echo ’';
43 : }

Do you have a mailserver running on the machine you have xampp on? If not you can’t use mail without setting the hostname and port of the mail server in the server config.

I strongly suggest using phpmailer or similar instead of mail(). It’s configurable to work with mail services, and actually give you sensible errors if something wrong happens

If you are just testing and do not actually need to send an email out you can use Papercut.
https://papercut.codeplex.com/

Description

Ever need to test emails from an application, but don't necessarily want it sending them out? Don't want to hassle with pointing it to a physical SMTP server? All you want to is verify it can send email, and take a look at the message.

Papercut is the answer. Papercut is a simplified SMTP server designed to only receive messages (not to send them on) with a GUI on top of it allowing you to see the messages it receives. It doesn’t enforce any restrictions on addresses, it just takes the message and allows you see it. It is only active while it is running, and if you want it in the background, just minimize it to the system tray. When it receives a new message, a balloon message will show up to let you know.

Sponsor our Newsletter | Privacy Policy | Terms of Service