I added some additional fields to the Contact form (using hook_form_alter()), and now I am trying to add these form values to the Contact form email output usinghook_mail_alter(&$message) :

function hook_mail_alter(&$message){
  $message['body'] .= "My added contact form field value will go here";
}

But the only thing being output in the email is 'Array'. Am I using this function correctly? I've read the api documentation: http://api.drupal.org/api/function/hook_mail_alter/6 but didn't find any more useful information on it.

Also, how can I change JUST the Contact form's email message. I've seen some posts that use $message['id'], but I'm not sure exactly what it is referring to or how to find it.

Any suggestions? Thanks

Comments

justageek’s picture

I think webform module has all this built in.

apersaud’s picture

I looked at contact.module more closely and looks like I had the syntax slightly wrong. This snippet allowed me to format the contact form email message:

function hook_mail_alter(&$message){
  $message['body'][] .= "My added contact form field value will go here";
}
ellanylea’s picture

Thanks for the snippet!

Remember: if your custom module is called mymodule.module, name the function mymodule_mail_alter, like this:

function mymodule_mail_alter(&$message){
  $message['body'][] .= "My added contact form field value will go here";
}
micheleannj’s picture

Just what I needed!

cheers,
m