Sending email for the custom form in WordPress

The easy way would install this plugin – https://da.wordpress.org/plugins/contact-form-7/ – It’s super easy to work with, and it will do what you want 🙂

If you don’t want to use a plugin, then you would just code a contact form with html and php.

PHP:

<?php
  $firstname = $_POST['firstname'];
  $lastname = $_POST['lastname'];
  $from = $_POST['email'];
  $message = $_POST['textarea'];

  $to = "[email protected]";
  $subject = "My subject";
  $message = "Hello world!";
  $headers = "From: " . $email . "\r\n" .
  "CC: [email protected]";

  mail($to,$subject,$message,$headers);
?>

HTML:

<form action="" method="post">
    First name:<br>
    <input type="text" name="firstname">
    <br>
    Last name:<br>
    <input type="text" name="lastname">
    <br>
    Email: <br>
    <input type="email" name="email">
    <br>
    Subject:<br>
    <input type="text" name="subject">
    <br>
    Message:<br>
    <textarea name="textarea" id="" cols="30" rows="10"></textarea>
    <br>
    <input type="submit" value="Submit">
</form>