How to use a drupal_mail function.
Let's say you want to send mail using drupal_mail function in your "test" custom module (test is an example name of module used below) after the form is submitted. You have to build two functions. First is a test_form_submit function, the second one is the test_mail function.
In the submit function you have to put the code below:
<?php
function test_form_submit($form, &$form_state) {
$to = "test@example.com"; // to e-mail address
$from = "test@example.com"; // from e-mail address
Read more