How to custom email and send with a cron job


I would like to use Keycloak for to manage the free trial role of my website and I not fount the answer for two questions.

  1. How create a new custom email (Hi, your free trial has ended…). I am a node developer and use the Keycloak NodeJS admin client (very good service !!!). is it possible to develop custom email with this SDK or I must develop my custom email with JAVA ?
  2. How manage 30 days period for remove free trial role only with Keycloak and cronjob ? (it’s more secure that use keycloak SDK with external service…).

Thank you !

1 Like

I would think that you need to build a small java class that calls the embedded email-sending-service. From there you can specify a custom template which pulls in custom messages which you store in a custom theme.
The java class can get its own endpoint if you like (/auth/realms// and authenticate the caller and then send out the customized mail.
So finally the cron would run curl…

I built this based on existing examples - if you like i can share an excerpt that could QuickStart you.
Another way would be a directly built java class that is run from cron and sends the email. I just don‘t have that built for you. This would require to run on the same box like Keycloak.