Index: contact.module =================================================================== RCS file: /cvs/drupal/drupal/modules/contact.module,v retrieving revision 1.1 diff -u -r1.1 contact.module --- contact.module 7 Dec 2004 17:03:46 -0000 1.1 +++ contact.module 2 Feb 2005 02:21:57 -0000 @@ -74,6 +74,9 @@ if (!$edit['message']) { form_set_error('message', t('You must enter a message.')); } + if (!$edit['subject']) { + form_set_error('subject', t('You must enter a subject.')); + } if (!form_get_errors()) { // Compose the body: @@ -86,13 +89,19 @@ // Tidy up the body: foreach ($message as $key => $value) { $message[$key] = wordwrap(strip_tags($value)); + } // Prepare all fields: $to = $account->mail; $from = $user->mail; - $subject = '['. variable_get('site_name', 'drupal') .'] '. t('message from %name', array('%name' => $user->name)); - $body = implode("\n\n", $message); + + // Format the subject + $subject = '['. variable_get('site_name', 'drupal') .'] '. $edit['subject']; + + $body = implode("\n\n", $message); + // Add a note at the beginning indicating which Drupal user sent this + $body = t('-- Contact message from: %name', array('%name' => $user->name) . $body; // Send the e-mail: user_mail($to, $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); @@ -114,6 +123,7 @@ $output = form_item(t('From'), $user->name .' <'. $user->mail .'>'); $output .= form_item(t('To'), $account->name); + $output .= form_textfield(t('Subject'), 'subject', $edit['subject'], 50, 8, NULL, NULL, TRUE); $output .= form_textarea(t('Message'), 'message', $edit['message'], 70, 8, NULL, NULL, TRUE); $output .= form_submit(t('Send e-mail')); $output = form($output);