- mail: documentation ( source)
<?php
if(isset($_POST['TO'])&&!empty($_POST['TO'])&&isset($_POST['from'])&&!empty($_POST['from']))
{
$to=$_POST['TO'];
$subject=$_POST['subject'];
$body=$_POST['body'];
$from=$_POST['from'];
if(mail($to,$subject,$body,$from))
{
echo 'Message sent';
}
else
echo 'Error in sending';
}
else
echo 'Enter the required fields';
?>
<form action="main.php" method="POST">
TO :<input type="text" name="TO"><br><br>
SUBJECT:<input type="text" name="subject"><br><br>
Message:<textarea name="body" rows="6" cols="30"></textarea><br><br>
From :<input type="text" name="from"><br><br>
<input type="submit" value="submit">
</form>