Skip to content

Instantly share code, notes, and snippets.

@JacobLett
Created February 15, 2019 15:24
Show Gist options
  • Select an option

  • Save JacobLett/9ab3e1a55bbce5d0ee221544349cba40 to your computer and use it in GitHub Desktop.

Select an option

Save JacobLett/9ab3e1a55bbce5d0ee221544349cba40 to your computer and use it in GitHub Desktop.
php email form
<?php
if($_POST["submit"]) {
$toEmail=$_POST["toEmail"];
$fromEmail=$_POST["fromEmail"];
$subject=$_POST["subject"];
$message=$_POST["message"];
$mailBody="From: $fromEmail\nTo: $toEmail\n\n$message";
mail($toEmail, $subject, $mailBody, "From: $fromEmail <$fromEmail>");
$thankYou="<p>Thank you! Your message has been sent.</p>";
}
?>
<?=$thankYou ?>
<form method="post" action="/test/">
<label>To email:</label>
<input name="toEmail">
<label>From email:</label>
<input name="fromEmail" value="">
<label>Subject:</label>
<input name="subject">
<label>Message:</label>
<textarea rows="5" cols="20" name="message"></textarea>
<input type="submit" name="submit">
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment