Is it possible to send an eMail when an user is created?

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

Is it possible to send an eMail when an user is created?

I'd like to send a notification mail to an user if it is created by the adminstrative user to the users email address.

9 Replies
Highlighted
Master

Re: Is it possible to send an eMail when an user is created?

There is no default functionality for this, but technically you could set up a rule on the people container node. This is not possible through the UI though. You could use content bootstrapping via a ImporterModuleComponent to load the rule set on Alfresco start. You would only have to create and export the rule set on another node (a folder where you can use the default UI) first. For exporting, you probably have to use the JavaScript Console to trigger the action since it is not exposed in the UI as well. JavaScript Console is also an alternative to using an ImporterModuleComponent to bootstrap / apply the rule set to the people container.

All in all you can see that it is possible though not one of the simpler customisations to apply to Alfresco.

Highlighted
Senior Member II

Re: Is it possible to send an eMail when an user is created?

Axels answer inspired me to another "inglorious workaround". You can also define a "onCreate" rule on the "User Homes" folder. This can be done via alfresco share.

This only works, if you are using the default user folder mechanism (flat style) and I don't know if it is working on background ldap-sync. 

This also could cause problems if you are bulk syncing/creating users - so first test it...

For getting more logic in your rule, you could execute a rule-script. I provide just a snippet for some of your demands:

function sendMailTo(toAdr, subject, mailtext) {
     var mail=actions.create("mail");
     mail.parameters.to=toAdr;
     mail.parameters.subject=subject;
     mail.parameters.from=">your alfresco email address>";
     mail.parameters.template=null;
     mail.parameters.text=mailtext;
     mail.execute(document);
}

function main() {
  var owner=document.getOwner();
  var userNode=people.getPerson(owner);
  var mailAdr=userNode.properties.email;
  var mailtext="Your useraccount was created.";
  sendMail(mailAdr, "Alfresco Useraccount", mailtext);
}

main();

...Just hacked it together from snippets I used - you would have to adopt, test and improve it...

Highlighted
Active Member

Re: Is it possible to send an eMail when an user is created?

Nice hack.

Is it also possible to send user information (like: username, password, email-address)? i think username and email-address is not the problem but password? Or is alfresco planing an module that will do that for me Smiley Happy?

Thanks for your help

Regards

Highlighted
Senior Member II

Re: Is it possible to send an eMail when an user is created?

You could create an admin WebScript or an Aikau or Angular SPA (single page app) that creates the user, sets a random password and sends the email to the user. If your WebScript or SPA generates the password, it's also possible to send it via email. But you have to create the users with your (see above Smiley Happy) created admin tool.

if you're using alfresco 5.2 there is a simple REST API to create your user, including plaintext password. See: Alfresco Content Services REST API Explorer 

but there should be an addon or something... wasn't there something created by ziaconsult?

Highlighted
Master

Re: Is it possible to send an eMail when an user is created?

You will not be able to send passwords either way since they have already been MD4 hashed by that point or may not exist at all (in case of sync from external directories). In order to send emails when local users are created AND include the password, you would need to hook yourself as an AOP interceptor on the (Mutable)AuthenticationService bean, though this would be sort of a non-standard customisation.

Highlighted
Senior Member II

Re: Is it possible to send an eMail when an user is created?

You could add all properties of the node (in this case userNode) that are returned by getPerson:

firstName, lastName, userName, email, organzationId, locale..

but not the password - see Axels answer.

Highlighted
Member II

Re: Is it possible to send an eMail when an user is created?

Can I use the email template, which is in Repository > Data Dictionary > Email Templates > invite > new-user-email.html.ftl

If yes.

How can I do this?

Thanks

Highlighted
Established Member

Re: Is it possible to send an eMail when an user is created?

Yes. You can do it in the following way using javascript

mail.parameters.template = companyhome.childByNamePath("your template path");

 

Regards,

Vidhi

Regards,
Vidhi | ContCentric
Highlighted
Member II

Re: Is it possible to send an eMail when an user is created?

hello vidhipanchal i real need your help in customizing Alfresco Workflow. Would real appreciate if you give me your email so that you can give me some help. My email is georgejslugendo@gmail.com. Its urgent