get php to send email from form

Solutions on MaxInterview for get php to send email from form by the best coders in the world

showing results for - "get php to send email from form"
Eduardo
26 Jan 2020
1<?php 
2if(isset($_POST['submit'])){
3    $to = "email@example.com"; // this is your Email address
4    $from = $_POST['email']; // this is the sender's Email address
5    $first_name = $_POST['first_name'];
6    $last_name = $_POST['last_name'];
7    $subject = "Form submission";
8    $subject2 = "Copy of your form submission";
9    $message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
10    $message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];
11
12    $headers = "From:" . $from;
13    $headers2 = "From:" . $to;
14    mail($to,$subject,$message,$headers);
15    mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
16    echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";
17    // You can also use header('Location: thank_you.php'); to redirect to another page.
18    }
19?>
20
21<!DOCTYPE html>
22<head>
23<title>Form submission</title>
24</head>
25<body>
26
27<form action="" method="post">
28First Name: <input type="text" name="first_name"><br>
29Last Name: <input type="text" name="last_name"><br>
30Email: <input type="text" name="email"><br>
31Message:<br><textarea rows="5" name="message" cols="30"></textarea><br>
32<input type="submit" name="submit" value="Submit">
33</form>
34
35</body>
36</html> 
queries leading to this page
sending html form data to an email address without phpphp form email sendsend form data email using phpsending form data to an email phpsend email through php formget form data and send to email using phpsending an email from form using phpphp form to email codesend html form to email phpsend email on form submit in html using phpform email submit php codeform action send email phpsending form data into an email phphow to send data from form to email and database in phpphp form post emailphp send form data to emailhtml form to php emailsend email form phphow to send email on form submission phpphp sending email formsend email using php after submitting formsimple php form to emailphp code for form submission to emailhow to send html form data to email using phpcontact form to send on email phpphp email from sendphp send emailhow to send email in php with htmlsend email when form is submitted phpphp send form to emailform to send email phpphp email formhow to send form into email using phpphp code to send form into emailsend email from html form with phpform email submit phpphp send email when post is submittedsend email using html form and phphow to make a working email form phpsimple form to send email phpphp form submit action and send emailphp send email formemail form data phphow to send form data to email using phpsend mail from html form using phpsend from in php mailhtml and php code for email sendhow to send email via php formphp submit form to emailhow to send email using phpsend email using php from a formphp code to send email from contact formsend email from php php code to send email for formsend email from form phpphp form send to mailphp form send emailphp form to emailsend email with php from html form on submithow to send email from php formsend html form data to email using phphow to send email in php with mail functionphp how to send an email from formsend email using phpphp send form mailsend form mail using mail php functionphp code to send email from a form submissionphp form send to emailget php to send email from form