Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions docs/core/plugins/mail_lua.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
layout: doc
title: mail-lua
dovecotlinks:
var_expand_lua: Variable expansion functions
---

# Mail Lua Plugin (`mail-lua`)
Expand All @@ -13,3 +15,58 @@ See [[link,lua]].
## Settings

<SettingsComponent plugin="mail-lua" />

## Variable expansion functions

This component registers two providers. Note that these providers have very
limited functionality at this moment.

### `%{lua_file(<path>,<function>,...)}`

Executes the script at given path, and if it's successful, use the string
result. If values are provided after function name, they are passed to
the Lua function as parameters. Pipeline value is always added last, if present.

Example:
```[dovecot.conf]
mail_plugins {
mail_lua = yes
}

mail_home = %{user|lua_file("/etc/dovecot/get_home.lua","get_home")}
```

```[get_home.lua]
-- This is not a good way to do this, provided here for example
-- purposes only. Do not use this.

local function get_home(user)
return "/home/" .. user
end
```

### `%{lua_call(<function>,...)}`

Executes Lua function in the [[setting,lua_file]], and if successful, use the string result. If values are provided after function name, they are passed to
the Lua function as parameters. Pipeline value is always added last, if present.

Example:
```[dovecot.conf]
mail_plugins {
mail_lua = yes
}

mail_lua {
lua_file = /etc/dovecot/mail.lua
}
mail_home = %{user|lua_call("get_home")}
```

```[mail.lua]
-- This is not a good way to do this, provided here for example
-- purposes only. Do not use this.

local function get_home(user)
return "/home/" .. user
end
```
Loading