example PHP formmail script

1) Sample PHP Form Code:

<form action=phpsend.php method=post>
<br>
Your Name:
<input type=text name=name>
<br>
E-mail:
<input type=text name=email>
<br>
<input type=submit value=Submit>
</form>
2) Create a file called phphsend.php with following code (modifying with your address):

<?
//Declare the variables of your form
$recipient = “USER@YOUR-DOMAIN-HERE.COM“;
$subject = “Testing.. 1 2 3”;
$message = “Hi there!”;
$from = “PHP mailer test”;
//Contents of form
$name=$_POST[‘name’];
$email =$_POST[’email’];
//mail() function sends the mail
mail($recipient,$subject,$message,$from,” -f VALID-USER@THISDOMAIN.COM);
?>

NOTE: -f VALID-USER@THISDOMAIN.COM needs to be a valid user on the local domain so that it will be able to send

Share on Twitter
Share on Facebook