mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
Updated Lua Examples (markdown)
@@ -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.
|
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
|
## Event trigger: after message stored
|
||||||
|
|
||||||
Prints metadata of stored messages to STDOUT:
|
Prints metadata of stored messages to STDOUT:
|
||||||
|
|||||||
Reference in New Issue
Block a user