Summer is almost over and it’s time to provide Mailtrain, the self hosted newsletter app, some new features.
LDAP
Mailtrain is now able to use centrally managed LDAP for user handling. This allows you to log in with the same credentials you use in other parts of your stack. Mailtrain has always been able to support multiple users but so far there has been no front-end to add and manage accounts and manually adding rows to MySQL database is not something most people are willing to do. LDAP is probably not too popular among smaller teams either and it is quite a handful to set up so one fine day there is going to be user management built directly into Mailtrain but that day is not arrived yet.
JSON data fields
One neat new feature is JSON data field. You can add a custom field to a list using the JSON datatype. It seems like a normal textarea but it expects JSON data instead of plain text. Whatever is stored in this field is rendered using a Handlebars template. This means that it is finally possible to use conditionals in Mailtrain newsletters. The downside is that the data inside JSON is not indexed, for example you can’t use it to build Segments. You can’t use the values throughout the message as well, the JSON data is only available inside the Handlebars template.
Here’s an example of such data field. As you can see you define that this is JSON data and you can also provide a template for rendering this data.

And here’s how you set the data for a subscriber. It’s a regular JSON string, use whatever schema you like to, no restrictions (beside the length of the data, no text field can be longer than 64kB). You can update this also by using the Mailtrain API (for the API it’s seems like a regular text field) or CSV import even though passing JSON through CSV seems strange at least.

And putting it all together, this is how a message looks like that includes the rendered JSON value

You can read all about the new JSON data type from the Mailtrain Wiki here.