<?php
if (isset($_POST['submit_button'])) {
$yourname = isset($_POST['yourname']) ? $_POST['yourname'] : '';
$youremail = isset($_POST['youremail']) ? $_POST['youremail'] : '';
$yourcomment = isset($_POST['yourcomment']) ? $_POST['yourcomment'] : '';
$total_content = "A new contact received from {$yourname}. \r\n";
$total_content .= "email address : {$youremail}\r\n";
$total_content .= "Comment : {$yourcomment}\r\n";
$to = '[email protected]';
$subject = "Your cool subject!";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
// @ supresses the error. You can still have the return in status
$status = @mail($to, $subject, $total_content, $headers);
}
?>
<html>
<form name="yourform" action="" method="post">
<?php if (isset($status)) {
if ($status) {
?>
Message sent successfully
<?php } else {
?>
Could not send the mail. Are you sure, the mail function is enabled on your server?
<?php }
}
?>
<br/>
Email: <input type="text" name="youremail"/> <br/>
Name:<input type="text" name="yourname"/><br/>
Comments:<textarea name="yourcomment"></textarea>
<br/><input type="submit" value="mailme" name="submit_button"/>
</form>
</html>