Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Last active December 16, 2015 08:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterdavis/5404879 to your computer and use it in GitHub Desktop.
Save walterdavis/5404879 to your computer and use it in GitHub Desktop.
<?php
foreach(explode(' ', 'from to subject message') as $field){
$$field = (isset($_POST[$field])) ? trim(strip_tags($_POST[$field])) : '';
}
if(isset($_POST['from'])){
mail($to, $subject, $message, 'From: ' . $from, '-f' . $from);
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Mail Test</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style type="text/css" media="screen">
label { display: block }
</style>
</head>
<body>
<form action="" method="post" accept-charset="utf-8">
<p>
<label for="from">From:</label>
<input type="email" name="from" id="from" value="<?php echo $from; ?>"/>
</p>
<p>
<label for="to">To:</label>
<input type="email" name="to" id="to" value="<?php echo $to; ?>"/>
</p>
<p>
<label for="subject">Subject:</label>
<input type="text" name="subject" id="subject" value="<?php echo $subject; ?>"/>
</p>
<p>
<label for="message">Message:</label>
<textarea name="message" id="message" rows="6" cols="40"><?php echo $message; ?></textarea>
</p>
<p><input type="submit" value="Send"/></p>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment