You are here

function theme_webform_mail_message in Webform 5.2

Theme the contents of e-mails sent by webform.

Parameters

$form_values: An array of all form values submitted by the user. The array contains three keys containing the following:

  • submitted: All the submitted values in a single array keyed by webform component IDs. Useful for simply looping over the values.
  • submitted_tree: All the submitted values in a tree-structure array, keyed by the Form Key values defined by the user.

$node: The complete node object for the webform.

$sid: The submission ID of the new submission.

$cid: If you desire to make different e-mails depending on the recipient, you can check this component ID to output different content. This will be the ID of the component that is a conditional e-mail recipient. For the normal e-mails, it will have the value of 'default'.

1 theme call to theme_webform_mail_message()
webform_client_form_submit in ./webform.module

File

./webform.module, line 1840

Code

function theme_webform_mail_message($form_values, $node, $sid, $cid) {
  global $user;
  $message = '';
  $message .= t('Submitted on') . ' ' . format_date(time(), 'small') . "\n";
  $ip_address = isset($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
  if ($user->uid) {
    $message .= t('Submitted by user') . ": {$user->name} [{$ip_address}]\n";
  }
  else {
    $message .= t('Submitted by anonymous user') . ": [{$ip_address}]\n";
  }
  $message .= "\n";
  $message .= t('Submitted values are:') . "\n\n";
  $message .= theme('webform_mail_fields', 0, $form_values['submitted_tree'], $node);
  $message .= "\n\n";
  $message .= t('The results of this submission may be viewed at:') . "\n";
  $message .= url('node/' . $node->nid . '/submission/' . $sid, NULL, NULL, TRUE);
  return $message;
}