NexusHerder
NexusHerder

Reputation: 11

Trying to use the mail function in PHP on a local host

I'm trying to use the mail function on a php website that I'm hosting on a local server (using USBWebServer v8.6) and I keep getting this error.

Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in E:\USBWebserver v8.6\root\insert.php on line 29

The code I'm using is getting data from a form have I missed something?

<?php
echo "Company Name: ".$_POST['companyname']."<br>";
echo "Address:  ".$_POST['address']."<br>";
echo "Phone Number: ".$_POST['phonenumber']."<br>";
echo "Email:    ".$_POST['email']."<br>";

mail($_POST['email'], "You have Registered", "You have Registered");
?>

The suggestion I keep getting is to do something to php.ini, but I'm confused as to what exactly I'd need to do

Upvotes: 1

Views: 885

Answers (1)

Typhomism
Typhomism

Reputation: 284

You have to fill out all parameters (unless you edit the PHP.ini file) to include all of the data, the mail() function accepts parameters like so:

mail($to, $subject, $body, $from);

however in order for the mail to actually be sent you also need to make sure your server is running a mail server.

Upvotes: 1

Related Questions