The global variable '$base_url' can optionally be set in settings.php for cases of issues with site domains.

When $base_url is set, Webform provides wrong URLs to results in mail messages it sends.

Here is a proposal to address this issue. It merely checks whether $base_url has been set and, if so, uses it instead of relying on $_SERVER['HTTP_HOST'].

function theme_webform_create_mailmessage($form_values, $node, $sid) {
  global $user, $baseurl, $base_url;
  $message .=  t('Submitted on') .' '. format_date(time(), 'small') ."\n";
  $ip_address = $_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');
  $message .= theme('webform_mail_fields', '', $form_values['submitted_tree'], $node);

  $message .= "\n\n";
  $message .= t("The results of this submission may be viewed at:\n");
  if (isset($base_url)) {
    $message .= $base_url . url('node/'.$node->nid, "sid=". $sid);
  }
  else {
    $message .= "http://". $_SERVER['HTTP_HOST'] . $baseurl . url('node/'.$node->nid, "sid=". $sid);
  }
...

By the way, the very same portion of code assumes that the protocol used is http, which is not always true.

Comments

quicksketch’s picture

Status: Needs review » Fixed

Sorry webform is still full of crusty code like this from 4.6 era (or earlier) :(

I replaced it with the proper solution of using url() with the absolute flag set.

  $message .= url('node/'.$node->nid, "sid=". $sid, NULL, TRUE);
Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.