I have tried using an approach as suggested in the below blog
https://is.docs.wso2.com/en/latest/develop/writing-a-custom-event-handler/
I have a requirement to send a custom email template when a user role is changed in the identity server.somehow I have figured out the event when we change the role. But I'm not getting a way to send a mail from a custom event handler. I would like to know if there is any other way to achieve this? Thanks in advance
All you need to do is trigger a
TRIGGER_NOTIFICATION
event from your event handler with some properties, then existing implementation of that event will get the template ID and fill the placeholders with the values passed in the event and send out the mail.This is be a sample code segment.
Here you need to replace
user
,oldRole
,newRole
andtemplateId
. In template management, you need to create a new email template with thistemplateId
and there you can design the email with these placeholders(OLD_ROLE
,NEW_ROLE
, for other placeholders you can refer to the existing templates.).You can find the event handler implementation of
TRIGGER_NOTIFICATION
here for any reference about this.