Clojure approaches to event-triggered emails?

My test-taking application needs to send emails based on events:

  • New user registration (to X, Y)
  • New test registration (to X, Y, Z)
  • Payment confirmation (to X, Y)
  • Test deadline approaching (to X)
  • Test complete notification (to X, Y)
  • Custom emails

I am so far using Postal + Selmer, so actually sending and creating emails is mostly taken care of. It’s the event system I’m working on now. What I’m thinking of is having a global map (perhaps Mount or from the DB) that links event-times with functions, and the application with different actions that subscribe to those events.

Before I reinvent the wheel, what solutions do you guys have? I see that the relevant Clojure Toolbox email solutions are years derelict and broken now.

I have one of my endless scripts doing this - what I found very useful was clojure.core.match to encode many rules of which template to use when. As what I send is often very low volume, I use a mailto: link so that the email can be edited and sent by my regular email client.

1 Like

Seconded @l3nz and the “endless script”. A program (separate from the front-end app) is a good way to go - instead of empowering all 99 of your webservers to send email. The web, telephone-IVR, and mobile front-ends poke things into a queue, which the business logic and email-sender feed from. You may find additional uses for such a queue. At an extreme, the queue is the backbone of the business, and the webservers do not even commit anything to the database except by enqueuing an event that a business daemon interprets into updates to the central relational or nosql database. The queue’s past events form a chronicle of events, which liberates the current-state database from having to kind-of try to save all sorts of quasi-historical crud.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.