<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {

    $email   = $_POST['email'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];

    //  basic validation
    if(empty($email) || empty($subject) || empty($message)){
        die("All fields required");
    }

    $to = "admin@yourdomain.com"; //  change this

    $fullMessage = "
    Email: $email\n
    Subject: $subject\n
    Message:\n$message
    ";

    $headers = "From: $email";

    if(mail($to, $subject, $fullMessage, $headers)){
        echo "success";
    } else {
        echo "error";
    }
}