I suppose you could add this to your theme's functions.php, but I'm not a theme dev, so don't quote me.
You'll need your endpoint function:
function sendMail() {
$to = $_POST ['to'];
$subject = $_POST ['subject'];
$message = $_POST ['message'];
wp_mail($to, $subject, $message); // send mail
wp_send_json_success(); // return and die
}
Then you'll need to hook it into WordPress:
if (is_admin ()) {
add_action ( 'wp_ajax_MyAwesomeMailFunction', 'sendMail' );
add_action ( 'wp_ajax_nopriv_MyAwesomeMailFunction', 'sendMail' );
}
.. where MyAwesomeMailFunction
is the action you'll use in your Ajax post.
Give the codex a read. https://codex.wordpress.org/AJAX