Hey folks,

I tried to improve the mail notification myself, but it did not work at all!

I'd like to have:

  • the subject telling me, if the new message is in my private guestbook or in the site guestbook
  • an introduction in the mail body, telling me, that the following message is new in my guestbook
  • the introduction in the mail body telling me, who left this message
  • a link, directling to the site / user guestbook
    • As I'm not able, to provide code, I can offer my help with the German translation of the subject and the mail body.

      Regards,
      forschi

Comments

andrenoronha’s picture

it would be good if we could customize the email with the help of tokens like other email notifications...

well, i wonder: where in the code of guestbook module is the intruction to send this email?

Anonymous’s picture

Have a look at guestbook.module around line 477

andrenoronha’s picture

Version: 6.x-2.x-dev » 6.x-1.1

I got what I wanted altering guestbook.module

on line 492 I took off the message:

    $params['body'] = '';

on line 521 I added the user variable
and on line 523 I changed $message['body'] to send in the email what I wanted:

/**
 * Implementation of hook_mail().
 */
function guestbook_mail($key, &$message, $params) {
  $language = $message['language'];
  $variables = user_mail_tokens($params['account'], $language);
  switch($key) {
    case 'notification':
      $user = $params['account'];
      $message['subject'] = t('New entry on !site', $variables, $language->language);
      $message['body'] = drupal_html_to_text(t("Hello $user->name! <br/>&nbsp;<br/> You got a new message on !site <br/> To see it go to !uri/user/$user->uid/guestbook", $variables, $language->language)) . drupal_html_to_text($params['body']);
      break;
  }
}

Now I ask: is there a way to do this without altering the code?

ajayg’s picture

Status: Active » Needs review
rakekniven’s picture

Hello,

I used 6.x 2.x dev for my mods.

Thanks a.luiz.n for your work.

I just modified "body" line in function guestbook_mail:

      $message['body'] = drupal_html_to_text(t("Hello $user->name! <br/>&nbsp;<br/> You got a new message on !site <br/> To see it go to !uri/guestbook <br/> &nbsp; <br/> Entry: <br/>", $variables, $language->language)) . drupal_html_to_text($params['body']);

It works pretty well for me.

On my site there is only a global website guestbook.

Would be happy to see something commited to dev.

Thumbs up for all drupal guys!