Hello,

How can I insert HTML into a webform submission email?

The token system strips/converts all HTML to text.

function mymodule_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'webform_client_form_whatever') {
$form['submitted']['whatever']['#value'] = "<strong>dynamic html is here</strong>";

However, in the email, the %email_values and %value[whatever], %email[whatever] etc. tokens are all not HTML - the HTML has been escaped.

How can I programmatically insert HTML into the email?

To clarify: sending HTML email is not the problem here - I am sending HTML email just fine (using MIME mail). The issue is Webforms is escaping any HTML in its tokens, and I do not know another way to programmatically insert HTML into a Webform email.

Thanks

Comments

Ivan Zugec’s picture

You'll need to setup Webform to Send HTML emails. The HTML mail module can be used to do it.

Here's a link to a Drupal answers post: https://drupal.stackexchange.com/a/29468/247

nedmartin’s picture

I am sending HTML emails just fine (using MIME mail), however as per original question (see code snippet), I cannot send HTML to the webform.

HTML placed in the email works fine. The issue is that Webforms escapes HTML in its tokens and I do not know another way to programattically insert HTML into the email.