Last updated 28 June 2011. Created on 28 June 2011.
Edited by Dublin Drupaller. Log in to edit this page.


I created the following snippet recently for a project where the default message text If you don't want to receive such e-mails...etc. and link to change a users personal contact form settings needed to be changed. Thought it might be of use to others.

Step 1 of 2

Copy the following snippet into a custom projectname_overrides.module and modify projectname to suit.

If you don't already have a projectname_overrides.module setup for your project. See below for a simple module .info file you can use.

*  Overriding the default user contact email
function projectname_overrides_mail_alter(&$message) {
  if ($message['id'] == 'contact_user_mail') {
     $argie = arg(1); //no $params available so pull the users UID from the arg 
     $message['body'][2] = t("If you don't want to receive such e-mails, you can change your Personal Contact Settings at the following link: !url.", array('!url' => url("user/$argie/edit", array('absolute' => TRUE, 'language' => $language))), $language->language); // this is specific for the drupal 6.x version of contact module. you may need to change the array key from 2 to something else if you are using a different version that changes the way the email body is put together.

Step 2 of 2

Enable the module. When you now send a message using a personal contact form, the text now reads:

If you don't want to receive such e-mails, you can change your Personal  
Contact Settings at the following link:

Where 7708 is obviously the recipients user id. file

Here's a file you can copy and use if you don't already have a custom projectname_overrides.module set up.

; $Id$
name = Custom Overrides
description = Custom overrides module
core = 6.x


  • Assumes clean urls are enabled
  • Tested by Dublin Drupaller june 2011 with drupal 6.x and pressflow
  • Please add a child page to this handbook page if you find an improvement or more efficient way of doing this
  • Ideally the core contact.module should be patched with an admin settings page form that allows admins to customise the default message text via the drupal admin gui

Looking for support? Visit the forums, or join #drupal-support in IRC.


westie’s picture

In order to change other parts of the body you might need to include:

$user = $message['params']['user'];
   $account = $message['params']['account'];

CTI Digital

angele1’s picture

Anyone experience in using this in Drupal 7? And should I use the module "module builder" for it?