views:

125

answers:

1

I'm trying to send a thank you email to the user submitting the form in HTML. I found out by using a hook in my template.php file like this works to set the header correctly:

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

  return $headers;
} 

This works freat for the "Thank You" email. The email that the site admin gets with the form results is also html, but it's not converting newlines to breaks in this email. I can't figure out how to use a hook for this, so I had to edit the webform.module file and do this:

function webform_mail($key, &$message, $params) {
  $message['headers'] = array_merge($message['headers'], $params['headers']);
  $message['subject'] = $params['subject'];
  //$message['body'][] = drupal_wrap_mail($params['message']); // replaced this with line below
  $message['body'][] = nl2br(drupal_wrap_mail($params['message']));
}

Can this be done with a hook in template.php?

thanks

A: 

You can use hook_mail_alter to edit mails created with hook_mail, which is what webform uses.

googletorp
I tried this but it's not working: function mythemename_mail_alter( } }
EricP