Edit email programatically just before it is sent

Hi,

I was wondering if there is a way (plugin?) to alter or verify an email just before it is sent out ?
Basically check the final text with a phpscript.

For instance, I could put a custom defined token ( [MY_TOKEN] ) in an email, and just before the email is actually sent out, replace [MY_TOKEN] with a programmatically created text based on that user’s attributes ?

At the moment I export all users, build the string for every user and add it to the list, then import the list again, putting the custom text in a self defined user attribute. I’d like to get rid of this step and don’t add stuff to the database that is only used once. Altering the email just before it is sent would be the solution here.

I assume the silence means there is no such standard(ized) solution ?

Next option then is to ‘hack’ the php to get this done.
Any suggestions in what file to start searching for the last ‘best’ point to change the content before it’s sent out ?

@ibPeter googling for “phplist write plugin” seems a good place to start. This is the documentation on writing a plugn https://resources.phplist.com/develop/plugins

Ok thanks @duncanc It was indeed quite easy to quickly put a plugin together that does exactly what I need.