Hello,

I have a problem with the Send tokenized e-mail action. I've entered the [author-mail] token into the recipient field but Drupal takes it literally (tries to send e-mails to [author-mail]) and node authors never receive any messages.

Am I doing something wrong?

CommentFileSizeAuthor
#7 load_node.diff2.4 KBmooffie

Comments

mooffie’s picture

Several questions:

1. Open 'token_node.inc' in an editor. Can you find the string 'author-mail' there? Perhaps you're using an old version.

2. Suppose you type some other node token in the recipient field, such as [author-name]. Will Token fail to expand it as well? Because if that's the case, then the problem isn't at all in the token [author-mail].

3. Suppose you type the [author-mail] token in the email body, will it get expanded correctly?

4. Do other node tokens expand correctly?

And why to you say "Drupal takes it [...]"? Drupal isn't involved here. Only the token module. Perhaps you're mistakenly using Drupal's own "send email" action?

mooffie’s picture

Another idea: perhaps you have two versions of the module installed (in different folders) and Drupal happens to pick the older one.

archetwist’s picture

Perhaps you're using an old version.

I wish it would be that simple ;) . No, I'm using the 6.x-1.11 version.

Suppose you type some other node token in the recipient field, such as [author-name]. Will Token fail to expand it as well? Because if that's the case, then the problem isn't at all in the token [author-mail].

You're right, other tokens don't get expanded as well.

Suppose you type the [author-mail] token in the email body, will it get expanded correctly?

No, it doesn't matter if I put it in the recipient or the body field.

Drupal isn't involved here. Only the token module. Perhaps you're mistakenly using Drupal's own "send email" action?

No, I'm using the "tokenized" one. I meant Drupal as a whole.

mooffie’s picture

So node tokens don't get expanded for you.

Do global tokens get expanded?

Global tokens as like [site-name], [site-date], [user-name], ...

mooffie’s picture

And to which "trigger" did you assign the action?

archetwist’s picture

I can receive the e-mail messages if I specify a "static" e-mail address so it's not a problem with triggers (I'm using the Trigger: After saving a new comment one).

I've tried the [site-url] and [site-name] tokens and they both work. [title] and [nid], on the other hand, don't. So it looks like a problem with node (and possibly comment - I haven't tried them yet) tokens. Global tokens seem to work.

mooffie’s picture

Status: Active » Needs review
StatusFileSize
new2.4 KB

so it's not a problem with triggers (I'm using the "Trigger: After saving a new comment" one).

It turns out to be a trigger problem.

The "After saving a new comment" trigger doesn't add the node object to the context. So the action doesn't see it.

The same happens with Drupal's own system_send_email_action(): it's the action itself which, given a comment, loads the node.

That's what we too should do.

I'm attaching a patch. In the same way we load 'user', so we should load 'node' --if a 'comment' object exists. I factored out the "normalization" process into a separate helper function.

archetwist’s picture

Title: Send tokenized e-mail action not working » Node tokens not working for actions
Category: support » bug
Status: Needs review » Reviewed & tested by the community

so it's not a problem with triggers

It turns out to be a trigger problem.

OK, I won't argue ;) .

I've applied the patch and the tokens I mentioned in my previous posts are working again so I think it's safe to change the status of this issue.

lop’s picture

This patch is working nicely for me too.

And I think there's duplicate patch at http://drupal.org/node/287614
(except the 'carriage return' issue)

mooffie’s picture

Title: Node tokens not working for actions » Node tokens not working for comment actions

Making the title more correct.

tobiassjosten’s picture

Patch is working well!

I am, however, still left without a working [url], [link] AND [path] token for comment actions. They are simply not substituted.

Encarte’s picture

subscribing

aterchin’s picture

Patch works fine for me too. Thanks. Tokens I'm using:

Recipient:
[author-mail]

Subject:
[site-name]
[type-name]
[title]

Message:
[comment-author-name]
[type-name]
[title]
[comment-body]
[site-url]
[comment-nid]
[comment-cid]
[site-url]
[nid]

danbuntu’s picture

This patch is working fine for me - any idea when it will be committed into the main module?

tobiassjosten’s picture

Does it really also work with the tokens I spoke of above, [url], [link] and [path]?

danbuntu’s picture

Actually [url], [link] and [path] aren't working for me.

Have noticed that there are two entries for these in the placeholder tokens section such as;

[url] Absolute path alias to the referenced user.

and

[url] Absolute path alias to the referenced node.

So i'm guessing this has something to do this.

I am succesfully using;

[author-name], [title], [site-url], [site-name], [comment-body]

greggles’s picture

Status: Reviewed & tested by the community » Fixed

If there are tokens that are the same between both node/user then that will definitely cause problems :( I'm not sure how to fix that - it's something that could be done during the upgrade to 7.x because it is a "major change requires manual intervention" kind of a thing. I created #412130: review all tokens for uniqueness and general sanity to cover that idea.

At first this patch felt overly complex to me (especially compared to the relatively lightweight change in #287614: support node tokens when a comment is posted in "send tokenized e-mail"). However, I think this reduces a lot of basically duplicate code and is a nice improvement.

Committed to 6.x branch. Thanks mooffie!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.