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.
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.
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.
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.
If you want to do it the right way, follow Martijn's directions above. If you want another dirty solution, do the following:
- make a copy of register.cpy
insert the following code:
context.MailHost.send('Content-Type: text/plain\n\n' + 'User has registered: ' + str(username),
mfrom='me@gmail.com',
mto='you@gmail.com',
subject='User Registration',
)