简体   繁体   English

Drupal:“发送电子邮件”操作无法将电子邮件发送到评论发布者

[英]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. 我按照该字段正下方的注释中的建议在操作配置表单的“收件人”字段中输入了[comment:author:mail] ,但似乎它从未发送过电子邮件。 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? 为什么[comment:author:mail]不起作用? I'm using other variables in the body of the email (eg [comment:node:title] ) and they're working fine. 我在电子邮件正文中使用了其他变量(例如[comment:node:title] ),它们工作正常。

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. 我尝试按照Drupal Answers的建议使用Maillog,它验证了问题不在于邮件传递,而在于电子邮件未正确填充。

Here's a screenshot that shows the email to the administrator is working correctly, but not the thank-you email: 下面的屏幕快照显示了发给管理员的电子邮件正在正常工作,但不显示感谢电子邮件:

在此处输入图片说明

Note: I originally posted this question on Drupal Answers. 注意:我最初将此问题发布在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. 我解决了这个问题,这要归功于下面接受的答案,也感谢对Drupal Answers的评论-我需要使用[comment:mail]而不是[comment:author:mail]以便它也可以与匿名评论者一起使用。 I didn't need to create a custom field, as it turned out. 事实证明,我不需要创建自定义字段。 For more info see https://drupal.stackexchange.com/a/126814/13378 有关更多信息,请参见https://drupal.stackexchange.com/a/126814/13378

The token [comment:author:mail] can only be used with registered users. 令牌[comment:author:mail]仅可用于注册用户。

Take a look at commet.token.inc 看看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。

Uid 0 is actually a user, tho it has no name, pass, or other information. Uid 0实际上是用户,没有名称,通行证或其他信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM