Files
Stalwart/tests/resources/smtp/config/rules-dynvalue.toml
2024-01-18 18:18:32 +01:00

64 lines
1.5 KiB
TOML

[envelope]
rcpt-domain = "foo.example.org"
rcpt = "user@foo.example.org"
sender-domain = "foo.net"
sender = "bill@foo.net"
local-ip = "192.168.9.3"
remote-ip = "A:B:C::D:E"
mx = "mx.somedomain.com"
authenticated-as = "john@foobar.org"
priority = -4
listener = "smtp"
helo-domain = "hi-domain.net"
[eval."eq"]
test = [
{if = "sender = 'bill@foo.net'", then = "sender"},
{else = false}
]
expect = "bill@foo.net"
[eval."starts-with"]
test = [
{if = "starts_with(rcpt_domain, 'foo')", then = "'mx.' + rcpt_domain"},
{else = false}
]
expect = "mx.foo.example.org"
[eval."regex"]
test = [
{if = "matches('^([^.]+)@([^.]+)\.(.+)$', rcpt)", then = "$1 + '+' + $2 + '@' + $3"},
{else = false}
]
expect = "user+foo@example.org"
[eval."regex-full"]
test = [
{if = "matches('^([^.]+)@([^.]+)\.(.+)$', rcpt)", then = "rcpt"},
{else = false}
]
expect = "user@foo.example.org"
[eval."envelope-match"]
test = [
{if = "matches('^([^.]+)@(.+)$', authenticated_as)", then = "'rcpt ' + rcpt + ' listener ' + listener + ' ip ' + local_ip + ' priority ' + priority"},
{else = false}
]
expect = "rcpt user@foo.example.org listener smtp ip 192.168.9.3 priority -4"
[eval."static-match"]
test = [
{if = "matches('^([^.]+)@(.+)$', authenticated_as)", then = "'hello world'"},
{else = false}
]
expect = "hello world"
[eval."no-match"]
test = [
{if = "matches('^([^.]+)@([^.]+)\.(.+)$org', authenticated_as)", then = "'test'"},
{else = false}
]
expect = false