*More fully fledged applications can be found on the Products page. The Bash page is dedicated to fully commented oneliners, and a MySQL quick reference is available here.
<?php
/* Will Bergen 2018
Simple joke tool, illustrating some basics of PHP's mail function
Send someone a nice fruit cup!
*/
if (isset($_POST["email_to"])){
echo "<b>Sending:</b><br>";
echo "<b>From:</b>" . $_POST["email_from"] . "<br>";
echo "<b>To:</b>" . $_POST["email_to"] . "<br>";
echo "<b>Name:</b>" . $_POST["email_name"] . "<br>";
echo "<b>Subject:</b>" . $_POST["email_subject"] . "<br>";
$to=$_POST["email_to"];
$from=$_POST["email_from"];
$name=$_POST["email_name"];
$subject = $_POST['email_subject'];
// We'll send a wee message, and a nice fruit cup:
$msg = "Buffalo Run West<br>";
$msg .= "<html><body><img src='https://www.cfacdn.com/img/order/COM/PDP_UPDATE/Images/Sides/%5BFeed%5D_0003s_0002_Sides_Fruit-Cup.png' alt='lol' height='256' width='256' title='Fruit Cup' style='display:block'/></body>";
// Use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);
echo $msg . "<br>";
// Headers:
$headers = "From: ".$name." <".$from.">\n";
$headers .= "Reply-To: ".$from."\n";
$headers .= "Content-Type: text/html; charset=UTF-8\n";
// Send Mail
mail($to, $subject, $msg, $headers);
}
?>
<html>
<body>
<form action="" method="post">
To: <input type="text" name="email_to"><br>
From: <input type="text" name="email_from"><br>
Name: <input type="text" name="email_name"><br>
Subject: <input type="text" name="email_subject"><br>
<input type=submit>
</form>
</body>
</html>