ZKRINET Docs
Building blocks

Email — Zkrinet plugin

On Zkrinet: add the block under Building blocks in the panel — one click, your own code is untouched and a snapshot is taken first. The installation steps below apply if you run PocketBase yourself, for example after an export.

Ready-made email templates that you edit in the admin panel, a function for sending them, and a log of everything sent. Tested against PocketBase 0.40.4.

Install

Copy pb_hooks/ and pb_migrations/ into your project and restart. Emails are sent via your own SMTP — configure it under Settings → Mail settings in the admin panel.

What you get

Send from your code

In your own hook (pb_hooks/*.pb.js):

const mejl = require(`${__hooks}/zk_mejl_lib.js`)
mejl.skicka($app, "notis", "anna@exempel.se", { namn: "Anna", rubrik: "New comment", meddelande: "Someone replied to you." })

Or via the API (requires superuser — call it from your server, never from the browser):

POST /api/zk/mejl   {"mall": "kvitto", "till": "anna@exempel.se", "data": {"namn": "Anna", "belopp": "99 kr", ...}}

Extra headers (for other plugins)

A fifth argument to skicka sets allowlisted headers — nothing else gets through:

mejl.skicka($app, "notis", "anna@exempel.se", { ... }, { svara_till: "bo@exempel.se", avregistrera: "https://…", ett_klick: true })

svara_till → Reply-To (a single valid address). avregistrera → List-Unsubscribe (https only), ett_klick → List-Unsubscribe-Post (RFC 8058). Values containing line breaks or in the wrong format are silently ignored — the email is sent without the header.

Security

Limitations