Passing variables in drupal_mail I have a custom module with form and I want to pass the values from form_state into email.
This is my code.

//The form page callback
function mymodule_page($form, &amp;$form_state) {
    $form['name'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('Enter name here'),
    );
    $form['surname'] = array(
        '#type' =&gt; 'textfield',
        '#title' =&gt; t('Enter surname here'),
    );
    $form['submit'] = array(
        '#type' =&gt; 'submit',
        '#value' =&gt; t('Submit'),
        '#submit' =&gt; array('mymodule_submit'),
    );

    return $form;
}

function mymodule_submit($form, &amp;$form_state) {
    $name = $form_state['values']['name']; 
    drupal_mail('mymodule', 'mymodule_mail', 'myemail', language_default(), array($name));
    dpm($form_state);
}

/**
 * Implements hook_mail().
 */
function custom_test_mail($key, &amp;$message, $params) {
    switch($key) {
        case 'mymodule_mail':

        $message['subject'] = t('Hello');
        $message['body'][] = t('This is a body text');

        break;
    }
}


I'm receiving the email with the subject and body, but without the value from $form['name'].

How can I pass the values from form fields?
You're already passing $name as a parameter, but you're not actually inserting it into the body so it won't show up in the email.

It's best to use a keyed array so you can easily refer to parameters by name, something like this:

$params = array('name' =&gt; $name);
drupal_mail('mymodule', 'mymodule_mail', 'myemail', language_default(), $params);

...

$message['body'][] = t('This is a body text');
$message['body'][] = t('Name: @name', array('@name' =&gt; $params['name']));