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?
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | load_node.diff | 2.4 KB | mooffie |
Comments
Comment #1
mooffie commentedSeveral 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?
Comment #2
mooffie commentedAnother idea: perhaps you have two versions of the module installed (in different folders) and Drupal happens to pick the older one.
Comment #3
archetwist commentedI wish it would be that simple ;) . No, I'm using the 6.x-1.11 version.
You're right, other tokens don't get expanded as well.
No, it doesn't matter if I put it in the recipient or the body field.
No, I'm using the "tokenized" one. I meant Drupal as a whole.
Comment #4
mooffie commentedSo node tokens don't get expanded for you.
Do global tokens get expanded?
Global tokens as like [site-name], [site-date], [user-name], ...
Comment #5
mooffie commentedAnd to which "trigger" did you assign the action?
Comment #6
archetwist commentedI 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 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.Comment #7
mooffie commentedIt 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.
Comment #8
archetwist commentedOK, 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.
Comment #9
lop commentedThis 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)
Comment #10
mooffie commentedMaking the title more correct.
Comment #11
tobiassjosten commentedPatch is working well!
I am, however, still left without a working [url], [link] AND [path] token for comment actions. They are simply not substituted.
Comment #12
Encarte commentedsubscribing
Comment #13
aterchin commentedPatch 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]
Comment #14
danbuntu commentedThis patch is working fine for me - any idea when it will be committed into the main module?
Comment #15
tobiassjosten commentedDoes it really also work with the tokens I spoke of above,
[url],[link]and[path]?Comment #16
danbuntu commentedActually [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]
Comment #17
gregglesIf 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!