D7: Create an administration page for my module I have a custom module that sends an email with an order to the customer. I hardcoded the email body text in a string inside the module code but my client want to have control over it and I need to create an admin page for him:


I need to save it and use that text as a variable.

I started the page like this:

function shop_admin_settings($form, &amp;$form_state) {
     $form = array();
     $form['mail_template'] = array(
       '#type' =&gt; 'fieldset',
       '#title' =&gt; t('Shop Email Template'),
       '#colapsed' =&gt; FALSE,
       '#collapsible' =&gt; TRUE,  
     );

     $form['mail_template']['body'] = array(
       '#type' =&gt; 'textarea',
       '#title'  =&gt; t('Email template'),
       '#rows' =&gt; 10,  
     );
     return system_settings_form($form);
 }


and use hook_mail_alter to append $form['mail_template']['body'] to the existing email body

function shop_mail_alter(&amp;$message, $form_state) {
$client_body = $form_state['mail_template']['body']
if (is_array($message['body'])) {
    $message['body'][] .= $client_body;
  }
}


Now if you please help me, I am a bit stuck: 


I need to retrieve the body provided by client, I don't know how (my code is not correct)
Do I need to create a separate admin.inc in order to work? Or do I simply need to add a menu path like admin/config/system/shop and a corresponding callback?
Is it possible for client to use tokens inside the body?
First of all hook_mail_alter() only has 1 parameter, no $form_state. Second of all, the system_settings_form() will save the form values into the variables table in the database. To access that value you should use variable_get().

Now, your code should look like this:

// try to change body to something more specific to your module, like custom_email_body
$form['mail_template']['custom_email_body'] = array( 
  '#type' =&gt; 'textarea',
  '#title'  =&gt; t('Email template'),
  '#default_value' =&gt; variable_get('custom_email_body', ''),
  '#rows' =&gt; 10,  
);


then:

function shop_mail_alter(&amp;$message) {
$client_body = variable_get('custom_email_body', '');
if (is_array($message['body'])) {
    $message['body'][] .= $client_body;
  }
}