Index: guestbook.module
===================================================================
--- guestbook.module	(revision 600)
+++ guestbook.module	(working copy)
@@ -524,17 +524,53 @@ function guestbook_form_entry_form_submi
   $guestbook_mode = variable_get('guestbook_mode', GUESTBOOK_SITE_GUESTBOOK | GUESTBOOK_USER_GUESTBOOKS);
   if ($uid == 0 && ($guestbook_mode & GUESTBOOK_SITE_GUESTBOOK)) {
     $iSendEmail = variable_get('guestbook_send_email', '');
+    // Build custom user object for e-mail body.
+    $guestbook_user = new stdClass;
+    $guestbook_user->uid = 0;
+    $guestbook_user->name = variable_get('site_name', t('Drupal'));
+    $guestbook_user->mail = $iSendEmail;
   }
-  else if ($guestbook_mode & GUESTBOOK_USER_GUESTBOOKS) {
+  else if ($uid > 0 && $guestbook_mode & GUESTBOOK_USER_GUESTBOOKS) {
     $guestbook_user = ($uid != $user->uid) ? user_load(array('uid' => $uid, 'status' => 1)) : $user;
     if ($guestbook_user->uid && empty($guestbook_user->guestbook_status) && !empty($guestbook_user->guestbook_send_email)) {
       $iSendEmail = $guestbook_user->mail;
     }
   }
 
-  $from = variable_get('site_mail', ini_get('sendmail_from'));
   if ($iSendEmail) {
-    drupal_mail('guestbook_notification', $iSendEmail, 'New guestbook entry', $message, $from);
+    // @todo Token/Notifications/Messaging/Subscriptions integration.
+    $tokens = array(
+      // Global tokens.
+      '[user-name]' => $user->uid ? $user->name : $edit['anonname'],
+      '[user-id]' => $user->uid ? $user->uid : 0,
+      '[site-name]' => variable_get('site_name', t('Drupal')),
+      '[site-url]' => $GLOBALS['base_url'],
+      // User tokens.
+      '[user]' => $user->uid ? check_plain($user->name) : check_plain($edit['anonname']),
+      '[user-raw]' => $user->uid ? $user->name : $edit['anonname'],
+      // Guestbook tokens.
+      '[guestbook-owner-raw]' => $guestbook_user->name,
+      '[guestbook-url]' => $guestbook_user->uid ? url("user/$guestbook_user->uid", NULL, NULL, TRUE) : url('guestbook', NULL, NULL, TRUE),
+      '[guestbook-entry-raw]' => $message,
+      // Notifications/Subscriptions tokens.
+      '[subscriptions-manage]' => $guestbook_user->uid ? url("user/$guestbook_user->uid/edit", NULL, NULL, TRUE) : url('guestbook', NULL, NULL, TRUE),
+    );
+    $mail_subject = strtr(t('New guestbook entry by [user-name]'), $tokens);
+    $mail_body = t('Hi [guestbook-owner-raw],
+
+[user-name] has signed your guestbook.
+
+Log in to [site-name] and go to [guestbook-url] to read the entry.
+
+Regards,
+The [site-name] team');
+    // Split mail body footer for future Notifications/Subscriptions integration.
+    $mail_body .= t('
+--
+This is an automatic message from [site-name].
+To manage your e-mail notifications browse to [subscriptions-manage].');
+    $mail_body = strtr($mail_body, $tokens);
+    drupal_mail('guestbook_notification', $iSendEmail, $mail_subject, $mail_body);
   }
 
   // Insert new message
