Matt Browne
Matt Browne

Reputation: 12419

Drupal: "Send email" action not working to send email to poster of comment

I have successfully set up email notifications on my client's blog for administrators when new comments are posted and am now trying to set it up to send a thank-you email to the poster of the comment as well. I set it up using triggers and actions as described here.

I put in [comment:author:mail] in the "Recipient" field on the action configuration form as suggested in the note right below that field, but it seems that it never sends the email. I initially tested it using my own email address and it worked fine, then I posted a comment as an anonymous user using two different email addresses of mine but never received an email. Why is [comment:author:mail] not working? I'm using other variables in the body of the email (e.g. [comment:node:title]) and they're working fine.

I tried using Maillog as was suggested on Drupal Answers, which verified that the problem isn't with mail delivery but rather with the email not being populated correctly.

Here's a screenshot that shows the email to the administrator is working correctly, but not the thank-you email:

enter image description here

Note: I originally posted this question on Drupal Answers. I hope it's not a problem that I'm re-posting it here, since no one there offered a resolution.


I solved it thanks to the accepted answer below, and thanks to a comment on Drupal Answers - I needed to use [comment:mail] instead of [comment:author:mail] so it would work with anonymous commenters too. I didn't need to create a custom field, as it turned out. For more info see https://drupal.stackexchange.com/a/126814/13378

Upvotes: 0

Views: 142

Answers (1)

BratAnon
BratAnon

Reputation: 326

The token [comment:author:mail] can only be used with registered users.

Take a look at commet.token.inc

if (($author_tokens = token_find_with_prefix($tokens, 'author')) && $account = user_load($comment->uid)) {
  $replacements += token_generate('user', $author_tokens, array('user' => $account), $options);
}

Unregistered users (anonymous users) will have uid 0.

Uid 0 is actually a user, tho it has no name, pass, or other information.

Upvotes: 1

Related Questions