From 9b399b50f3c2f85657b30b989833fc7acea4d9ca Mon Sep 17 00:00:00 2001 From: James Hillyerd Date: Tue, 28 Feb 2023 11:52:11 -0800 Subject: [PATCH] Updated Lua Examples (markdown) --- Lua-Examples.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Lua-Examples.md b/Lua-Examples.md index 3d4f11e..ebf3a21 100644 --- a/Lua-Examples.md +++ b/Lua-Examples.md @@ -2,5 +2,21 @@ By default Inbucket will load `inbucket.lua`, but you may use the `INBUCKET_LUA_ ## Event trigger: after message stored -Example prints details for each message stored to STDOUT. +```lua +-- Prints metadata of stored messages to STDOUT. +function inbucket.after.message_stored(msg) + print("\n## message_stored ##") + print(string.format("mailbox: %s", msg.mailbox)) + print(string.format("id: %s", msg.id)) + print(string.format("from: %q <%s>", + msg.from.name, msg.from.address)) + + for i, to in ipairs(msg.to) do + print(string.format("to[%s]: %q <%s>", i, to.name, to.address)) + end + + print(string.format("date: %s", os.date("%c", msg.date))) + print(string.format("subject: %s", msg.subject)) +end +``` \ No newline at end of file