How send mail any form details fill

You want to know how to send an email with form details filled in. Here are a few ways to do it:

Method 1: Using a simple HTML form and PHP

  1. Create an HTML form with the fields you want to send:
    <form action="send_email.php" method="post">
    <input type="text" name="name" placeholder="Name">
    <input type="email" name="email" placeholder="Email">
    <textarea name="message" placeholder="Message"></textarea>
    <input type="submit" value="Send">
    </form>
  2. Create a PHP file (send_email.php) to process the form data and send the email:
    
    <?php
    // Get the form data
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];

// Set the email recipient and subject $to = '[email protected]'; $subject = 'Form Submission';

// Create the email message $message = "Name: $name\nEmail: $email\nMessage: $message";

// Send the email using PHP's mail function mail($to, $subject, $message);

// Redirect the user to a thank-you page header('Location: thank-you.php'); exit; ?>

**Method 2: Using a JavaScript library like jQuery and a PHP backend**

1. Create an HTML form with the fields you want to send:
```html
<form id="myForm">
  <input type="text" name="name" placeholder="Name">
  <input type="email" name="email" placeholder="Email">
  <textarea name="message" placeholder="Message"></textarea>
  <input type="submit" value="Send">
</form>
  1. Use jQuery to serialize the form data and send it to your PHP backend:
    $('#myForm').submit(function(event) {
    event.preventDefault();
    var formData = $(this).serialize();
    $.ajax({
     type: 'POST',
     url: 'send_email.php',
     data: formData,
     success: function(data) {
       // Redirect the user to a thank-you page
       window.location.href = 'thank-you.php';
     }
    });
    });
  2. Create a PHP file (send_email.php) to process the form data and send the email:
    
    <?php
    // Get the form data
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];

// Set the email recipient and subject $to = '[email protected]'; $subject = 'Form Submission';

// Create the email message $message = "Name: $name\nEmail: $email\nMessage: $message";

// Send the email using PHP's mail function mail($to, $subject, $message);

// Redirect the user to a thank-you page header('Location: thank-you.php'); exit; ?>

**Method 3: Using a JavaScript library like React and a PHP backend**

1. Create an HTML form with the fields you want to send:
```html
<form>
  <input type="text" name="name" placeholder="Name">
  <input type="email" name="email" placeholder="Email">
  <textarea name="message" placeholder="Message"></textarea>
  <button type="submit">Send</button>
</form>
  1. Use React to handle the form submission and send the data to your PHP backend:
    
    import React, { useState } from 'react';

function MyForm() { const [name, setName] = useState(''); const [email, setEmail] = useState(''); const [message, setMessage] = useState('');

const handleSubmit = (event) => { event.preventDefault(); fetch('/send_email.php', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name, email, message }), }) .then((response) => response.json()) .then((data) => { // Redirect the user to a thank-you page window.location.href = 'thank-you.php'; }); };

return (

setName(event.target.value)} /> setEmail(event.target.value)} />