1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 09:37:02 +00:00

Updated Lua Examples (markdown)

James Hillyerd
2023-02-28 13:49:01 -08:00
parent 9d6cd87df0
commit 67aaa26b52

@@ -1,5 +1,31 @@
**Warning**: Lua support in Inbucket is still in a preview state, please expect the API and features to evolve before a full release.
By default Inbucket will load `inbucket.lua`, but you may use the `INBUCKET_LUA_PATH` environment variable to change that.
## Event trigger: before mail accepted
This event fires when Inbucket is evaluating an SMTP "MAIL FROM" command.
Denies mail that does is not from james*@example.com:
```lua
function inbucket.before.mail_accepted(from_localpart, from_domain)
print(string.format("\n### inspecting from %s@%s", from_localpart, from_domain))
if from_domain ~= "example.com" then
-- Only allow example.com mail
return false
end
if string.find(from_localpart, "james") ~= 1 then
-- Only allow mailboxes starting with 'james'
return false
end
return true
end
```
## Event trigger: after message stored
Prints metadata of stored messages to STDOUT: