<?php
// this code must be on some.php file on hosting. You can not use this code on localhost PC!
// change webmaster@example.com in what you want!
if (isset($_REQUEST['to'])) {
//Email information
$to= $_REQUEST['to'];
$from = $_REQUEST['from'];
$subject = $_REQUEST['subject'];
$message = $_REQUEST['message'];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <webmaster@example.com>' . "\r\n";
//send email
mail($to, $subject, $message, $headers);
//Email response
echo "Thank you for sending email!";
}
//if "email" variable is not filled out, display the form
else {
?>
<form method="post">
From: webmaster@example.com <br />
To: <input name="to" type="text" /><br />
Subject: <input name="subject" type="text" /><br />
Message:<br />
<textarea name="message" rows="15" cols="40"></textarea><br />
<input type="submit" value="Submit" />
</form>
<?php
}
?>
No comments:
Post a Comment