Hello,

First, my apologies if this is a stupid question or duplicate. I've searched for an answer for this to no avail.

I'm trying to have Webform send out an HTML formatted email - I've added

function mytheme_webform_mail_headers($form_values, $node, $sid, $cid) {
  $headers = array(
    'Content-Type'  => 'text/html; charset=UTF-8; format=flowed; delsp=yes',
    'X-Mailer'      => 'Drupal Webform (PHP/'. phpversion() .')',
  );
  return $headers;
}  

to my template.php file (replacing 'mytheme' with my theme name) and Webform is generating the html email just fine.

I've copied over the 'webform-mail.tpl.php' to my theme folder, made modifications and that's all good too.

My issue is this
print theme('webform_mail_fields', '', $form_values['submitted_tree'], $node);

is returning everything without any linebreaks - no formatting at all. I know I could call every form value like this: http://drupal.org/node/399064 but I'd rather not for several reasons (having to alter the hard-coded email template every time a change is made being the most important).

Is there any way to add in linebreaks / html formatting after every form label/value combination? I'm sure if I were better with php the answer would be obvious...

Thanks
James

Comments

occupant’s picture

Status: Active » Closed (fixed)

Ok, I figured it out. I needed to add the nl2br function (converts linebreaks to <br>s). So I ended up with this:

print nl2br(theme('webform_mail_fields', 0, $form_values['submitted_tree'], $node));

Hope this helps some other poor php-challenged individual :)

gettysburger’s picture

I've been struggling with the same problem, so this is a help. But I'm wondering this:

The non-html output of this (print theme('webform_mail_fields', 0, $form_values['submitted_tree'], $node);) returns a simple page with what looks like an unordered list with the fieldsets as the titles of the list - nice, but all of the formatting is stripped when I make into html.

How do I maintain this formatting and/or control it with CSS? It seems that it knows what kind of list elements the items are when it formats the non-html version, but all of that is stripped when surrounded by the html tag.