diff -urp ../autoassignrole-6.x-1.x-dev/autoassignrole-admin.inc ./autoassignrole-admin.inc
--- ../autoassignrole-6.x-1.x-dev/autoassignrole-admin.inc	2009-12-14 20:37:23.000000000 +0100
+++ ./autoassignrole-admin.inc	2010-02-25 21:20:49.000000000 +0100
@@ -74,7 +74,7 @@ function autoassignrole_admin_form() {
     '#default_value' => $default,
     '#weight' => -1,
   );
-  $result = db_query("SELECT rid, display, path, title, description, format, weight, menu, registration FROM {autoassignrole_page}");
+  $result = db_query("SELECT rid, display, path, title, description, format, weight, menu, registration, email_subject, email_body FROM {autoassignrole_page}");
   $defaults = array();
   while ($setting = db_fetch_object($result)) {
     $defaults[$setting->rid] = array(
@@ -86,6 +86,8 @@ function autoassignrole_admin_form() {
       'weight' => $setting->weight,
       'menu' => $setting->menu,
       'registration' => $setting->registration,
+      'email_subject' => $setting->email_subject,
+      'email_body' => $setting->email_body,
     );
   }
   foreach ($roles as $k => $v) {
@@ -158,6 +160,22 @@ function autoassignrole_admin_form() {
       '#default_value' => (isset($defaults[$k]['description']) ? $defaults[$k]['description'] : ''),
       '#required' => FALSE,
     );
+    $form['autoassignrole_settings_page'][$k]["path_email_subject_$k"] = array(
+      '#type' => 'textfield',
+      '#title' => t('Email subject'),
+      '#description' => t('The subject of the welcome email send to the user. Leave empty to use the default from the User settings page.'),
+      '#default_value' => (isset($defaults[$k]['email_subject']) ? $defaults[$k]['email_subject'] : ''),
+      '#size' => 60,
+      '#maxlength' => 180,
+      '#required' => FALSE,
+    );
+    $form['autoassignrole_settings_page'][$k]["path_email_body_$k"] = array(
+      '#type' => 'textarea',
+      '#title' => t('Email Body'),
+      '#description' => t('The body of the welcome email send to the user. Leave empty to use the default from the User settings page.'),
+      '#default_value' => (isset($defaults[$k]['email_body']) ? $defaults[$k]['email_body'] : ''),
+      '#required' => FALSE,
+    );
     $format = (isset($defaults[$k]['format']) ? $defaults[$k]['format'] : FILTER_FORMAT_DEFAULT);
     $form['autoassignrole_settings_page'][$k]["format"] = filter_form($format);
     foreach ($form['autoassignrole_settings_page'][$k]["format"] as $key => $value) {
@@ -373,7 +391,9 @@ function autoassignrole_admin_form_submi
       $weight = $form_state['values']["path_weight_$k"];
       $menu = $form_state['values']["path_menu_$k"];
       $registration = $form_state['values']["path_registration_$k"];
-      db_query("INSERT INTO {autoassignrole_page} (rid, display, path, title, description, format, weight, menu, registration) VALUES(%d, '%s', '%s', '%s', '%s', %d, %d, '%s', %d)", $k, $display, $path, $title, $description, $format, $weight, $menu, $registration);
+      $email_subject = $form_state['values']["path_email_subject_$k"];
+      $email_body = $form_state['values']["path_email_body_$k"];
+      db_query("INSERT INTO {autoassignrole_page} (rid, display, path, title, description, format, weight, menu, registration, email_subject, email_body) VALUES(%d, '%s', '%s', '%s', '%s', %d, %d, '%s', %d, '%s', '%s')", $k, $display, $path, $title, $description, $format, $weight, $menu, $registration, $email_subject, $email_body);
     }
   }
   // rebuild the menu
diff -urp ../autoassignrole-6.x-1.x-dev/autoassignrole.install ./autoassignrole.install
--- ../autoassignrole-6.x-1.x-dev/autoassignrole.install	2009-08-25 15:04:44.000000000 +0200
+++ ./autoassignrole.install	2010-02-25 21:18:21.000000000 +0100
@@ -117,6 +117,18 @@ function autoassignrole_schema() {
         'default' => 0,
         'description' => t('Should this item replace the default user registration page.'),
       ),
+      'email_subject' => array(
+        'type' => 'varchar',
+        'length' => 180,
+        'not null' => TRUE,
+        'description' => t('The subject of the welcome email send to the user.'),
+      ),
+      'email_body' => array(
+        'type' => 'text',
+        'size' => 'big',
+        'not null' => FALSE,
+        'description' => t('The body of the welcome email send to the user.'),
+      ),
     ),
     'primary key' => array('rid'),
   );
@@ -239,3 +251,18 @@ function autoassignrole_update_6005() {
   }
   return $ret;
 }
+
+/**
+ * Add email_body and email_subject for role specific registration emails.
+ * See http://drupal.org/node/267848
+ */
+function autoassignrole_update_6006() {
+  $ret = array();
+  if (!db_column_exists('autoassignrole_page', 'email_subject')) {
+    $ret[] = update_sql('ALTER TABLE {autoassignrole_page} ADD email_subject VARCHAR(180)');
+  }
+  if (!db_column_exists('autoassignrole_page', 'email_body')) {
+    $ret[] = update_sql('ALTER TABLE {autoassignrole_page} ADD email_body TEXT');
+  }
+  return $ret;
+}
diff -urp ../autoassignrole-6.x-1.x-dev/autoassignrole.module ./autoassignrole.module
--- ../autoassignrole-6.x-1.x-dev/autoassignrole.module	2009-12-23 14:59:15.000000000 +0100
+++ ./autoassignrole.module	2010-02-25 21:43:50.000000000 +0100
@@ -582,3 +582,43 @@ function autoassignrole_menu_alter(&$ite
     $items['user/register']['type'] = MENU_LOCAL_TASK;
   }
 }
+
+/**
+ * Replace the Welcome email send by the user.module by role dependent text.
+ * 
+ * Implementation of hook_mail_alter().
+ */
+function autoassignrole_mail_alter(&$message) {
+  // No register email - go out
+  if (!preg_match('/^user_register.+/', $message['id'])) {
+    return;
+  }
+  
+  // Get the role of the user
+  $rid = '';
+  foreach($message['params']['account']->roles as $rid => $value) {
+    // Only interested in the first Role which is not "authenticated user"
+    if (DRUPAL_AUTHENTICATED_RID != $rid) {
+      break;
+    }
+  }
+  
+  // No role detected - go out
+  if('' == $rid) {
+    return;
+  }
+  
+  // Get role specific mail text
+  $email_text = db_fetch_array(db_query('SELECT email_subject, email_body FROM {autoassignrole_page} WHERE rid = %d', $rid));
+
+  // No data for the email - go out
+  if (empty($email_text['email_subject']) && empty($email_text['email_body'])) {
+    return;
+  }
+  
+  // Replace the mail text generated by the user.module using the 
+  // role specific email body and the mail tokens from the user.module
+  $message['body'][0] = t($email_text['email_body'], user_mail_tokens($message['params']['account'], $message['language']));
+  $message['subject'] = t($email_text['email_subject'], user_mail_tokens($message['params']['account'], $message['language']));
+}
+
