Plone 中是否有一种简单的方法可以在新用户加入门户时收到电子邮件通知?
我希望每当新用户加入门户时都会向门户电子邮件地址发送电子邮件通知。
我的猜测是我应该编写一个新产品来做到这一点。
这样的产品是否已经存在(针对 Plone 4)?
我检查了内容规则,但据我所知,只有当我让用户对膜/记住之类的东西感到满意时,它才能起作用,但对于我的要求来说,这有点过分了。
I want to get email notifications to the portal email address whenever a new user joins the portal.
My guess is that I should code a new product to do that.
Does such product already exist (for Plone 4)?
I checked content rules, but AFAICT it could work only if I made the users contentish themselves with something like membrane/remember, but for my requirements that would be overkill.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为这样的产品还不存在。
创建一个添加内容规则条件的包应该很简单,它可以让您为
Products.PluggableAuthService.interfaces.events.IPrincipalCreatedEvent
事件。Plone 知识库记录了如何创建此类包。
I don't think such a product already exists.
It should be trivial to create a package that adds a content rule condition, that would let you write a content rule for the
Products.PluggableAuthService.interfaces.events.IPrincipalCreatedEvent
event.The Plone knowledgebase documents how to create such a package.
您可以轻松自定义 Registered.pt 模板,添加对 PythonScript 的简单调用,通过 MailHost api 发送电子邮件。
对 plone.app.users.browser.register.py 进行适当的定制要复杂得多。
You can easily customize the registered.pt template add a simple call to a PythonScript sending out an email through the MailHost api.
Doing a proper customization of plone.app.users.browser.register.py is much more complex.
您还可以让login_next遍历您编写的发送电子邮件的控制器Python脚本(您将在核心Plone产品的/plone_login区域中以扩展名'.cpy'结尾的其他类似脚本中进行罚款)(可能是notifyMangersUponLogin )而不是默认遍历到login_success。
然后,让你的 CPT 脚本遍历到 login_success 以继续 Plone 附带的脚本/页面 MVC 流程(如果这是你想要的)。
要利用控制器页面模板(.cpt 文件)/脚本(.cpy 文件),不仅要将自定义版本的 login_next.cpy 复制到自定义产品的皮肤路径,还要复制指定的 login.cpy.metadata 文件。 MVC 页面/脚本逻辑流的成功/失败操作。
使用 Plone 4.0.2,您将在以下路径下找到与 Plone 登录相关的脚本/模板:
/buildout-cache/eggs/plone-4.0.2-py2.6.egg/产品/CMFPlone/skins/plone_login
相对于您的扩建结构。
You can also just have login_next traverse to a Controller Python Script (you'll fine other similar ones in the /plone_login area of the core Plone product that end with the extension '.cpy') that you write that sends the email (perhaps notifyMangersUponLogin ) rather than it's default of traversing to login_success.
Then, have your CPT script traverse to login_success to continue the sript/page MVC flow that Plone ships with, if that's what you want.
To leverage Controller Page Templates (.cpt files)/Scripts (.cpy files), it's key to not only copy the custom version of login_next.cpy to your custom product's skin path, but also the login.cpy.metadata file that specifies the success/failure actions of the MVC page/script logic flow.
With Plone 4.0.2, you'll find the Plone login-related scripts/templates under a path such as:
/buildout-cache/eggs/plone-4.0.2-py2.6.egg/Products/CMFPlone/skins/plone_login
relative to your buildout structure.
如果您想以正确的方式进行操作,请按照上面 Martijn 的指示进行操作。如果您想要另一个肮脏的解决方案,请执行以下操作:
插入以下代码:
context.MailHost.send('内容类型:text/plain\n\n' + '用户已注册:' + str(用户名),
mfrom='[电子邮件受保护]',
mto='[电子邮件受保护]',
subject='用户注册',
)
If you want to do it the right way, follow Martijn's directions above. If you want another dirty solution, do the following:
insert the following code:
context.MailHost.send('Content-Type: text/plain\n\n' + 'User has registered: ' + str(username),
mfrom='[email protected]',
mto='[email protected]',
subject='User Registration',
)